generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: GetPlayerFromCharacter problem

Previous Thread :: Next Thread 
PanzerSchmit is not online. PanzerSchmit
Joined: 09 Apr 2009
Total Posts: 789
07 Jul 2014 08:58 AM
Water = script.Parent

function onTouch(hit)
RL = hit.Parent:FindFirstChild("Right Leg")
Player = hit.Parent
LPlayer = Player:GetPlayerFromCharacter(Noob)
if (RL ~= nil) then
wait(0.1)
Noob.PlayerGui.WaterSplash:Play()
for i=4,9 do
local splash = Instance.new("Part")
splash.Shape = 0
splash.formFactor = 3
splash.Size = Vector3.new(0.2,0.2,0.2)
splash.BrickColor = BrickColor.new(23)
splash.BottomSurface = 0
splash.TopSurface = 0
splash.CanCollide = false
splash.Transparency = 0.3
local v = Vector3.new(math.random(-1,1), math.random(0,1), math.random(-2,1))
splash.Velocity = 35 * v
splash.CFrame = CFrame.new(rl.Position + v, v)
splash.Parent = game.Workspace
end
end
end

Water.Touched:connect(onTouch)

--
That script is placed into Terrain. If someone touches terrain, its doing splash effect and it should play splash music from PlayerGui. Somehow it doesnt work. Output says :
15:58:30.835 - GetPlayerFromCharacter is not a valid member of Workspace
15:58:30.835 - Script 'Workspace.Terrain.Splash', Line 6
15:58:30.835 - Stack End
15:58:30.835 - Disconnected event because of exception
Report Abuse
AnonyAnonymous is not online. AnonyAnonymous
Joined: 23 Jun 2013
Total Posts: 6332
07 Jul 2014 09:00 AM
Add a check to make sure "hit" actually belongs to a player.
Report Abuse
DataStore is not online. DataStore
Joined: 07 Feb 2012
Total Posts: 8540
07 Jul 2014 09:03 AM
GetPlayerFromCharacter is a method used on the players service, not models.

game.Players:GetPlayerFromCharacter(hit.Parent)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image