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 » Scripters
Home Search
 

Re: Couldn't get the Character inside the game

Previous Thread :: Next Thread 
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
23 Jan 2017 05:34 AM
The Animation and the flashlight runs perfectly in Roblox Studio but when i join the place with the Ro##########his happens:
Players.RomDino.Backpack.Flashlight.ShakeLight:2:attempt to index local 'player' (a nil value)

Error at line 2, I couldn't know what to fix. I tried moving it and changed it but it still doesn't work

Here is the full script:

local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:WaitForChild("Humanoid");
if not character or not character.Parent then
character = player.CharacterAdded:wait()
end
local tool = script.Parent;
local shake1 = tool.Handle:WaitForChild("FirstShake");
local shake2 = tool.Handle:WaitForChild("SecondShake");
local handle = tool:WaitForChild("Handle");
local spotLight = handle:WaitForChild("SpotLight");
local remoteEvent = tool:WaitForChild("RemoteEvent");
remoteEvent.OnServerEvent:Connect(function(player)
if (spotLight.Brightness >= 2) then
spotLight.Brightness = 2
else
local anim_feet = hum:LoadAnimation(script.Parent.Animation)
local current = anim_feet
current:Play()
shake1:Play()
wait(0.15)
shake2:Play()
spotLight.Brightness = spotLight.Brightness + 0.35;
end
end)
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
23 Jan 2017 06:01 AM
Use a localscript
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
23 Jan 2017 06:03 AM
I did but it says: Event only use for Server
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
23 Jan 2017 07:42 AM
Choose one:
You can only use RemoteEvent.OnServerEvent from regular (server) scripts
You can only use Players.LocalPlayer from localscripts.


I'd recommend using RemoteEvent.OnClientEvent
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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