Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

This Flashlight tool works perfectly fine in the Roblox Studio but it doesn't run in RobloxBeta?

This TOOL's script works in Roblox Studio but it doesn't work in the real Roblox Place (RobloxBeta) It says that: Players.RomDino.Backpack.Flashlight.ShakeLight:2:attempt to index local 'player' (a nil value)

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) 

If anybody can fix this then thank you

3 comments

0

is this a local script?

0

Is this a local script? LocalPlayer only works in LocalScripts which HAVE to be inside the player for it work.

0

Is there a way I can get the Humanoid Character without using Local Script? Local Script crashes this script!

1 answer

Could there be a way to get the Character without using Local Script? I couldn't turn it to Local Script because it would crashes the script!

This discussion is preserved as it was. New answers, comments, and votes are closed.