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

Problem with local script - why does this text button only work in Studio mode?

So when a player clicks on this text button, they get a purple fire in their torso.

local Player = game.Players.LocalPlayer
local Torso = Player.Character.Torso
debounce = true
function onClicked()
	if Player.leaderstats.NeonBux.Value>=10 and debounce == true then
		Player.leaderstats.NeonBux.Value=Player.leaderstats.NeonBux.Value-10
     	local Fire = script.Parent.Fire:Clone() --both localscript and fire is inside text button
		Fire.Parent = Torso
		debounce = false
     	wait(5)
		debounce = true
    end
end
script.Parent.MouseButton1Down:connect(onClicked)

7 comments

0

LocalScript or ServerScript?

0

LocalScript as mentioned

0

Overlooked that, sorry. Any errors in output or developer console?

0

There are errors about decals failing to load, but nothing about the code itself

0

Wait at the top it says in red "LocalPlayer is a not a valid member of Player"?

0

Nvm I fixed that error, but the script still doesn't work in Server mode

0

You need to have the script wait for the torso to load in,

2 answers

QuantumToast is right mate I cant see any other errors either you need the Torso variable to look like this:

local Torso = Player.Character:WaitForChild("Torso")

Give QuantumToast credit if it works not me.

Put wait(.1) at the top of the script. Then try it.

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