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

Why is this local script not working?

Okay so I have this textbutton that gives tools in a class and it works in solo mode but not in play mode. Here is my script:

wait(1)
button = script.Parent
local dbounce = false
function hi()
	if dbounce == false then
		dbounce = true
		script.Parent.Parent.TextButton.LocalScript:Destroy() -- Note this is destroying a different script
	game.ServerStorage.LinkedSword:clone().Parent = game.Players.LocalPlayer.Backpack
	game.ServerStorage.LinkedPaintballGun:clone().Parent = game.Players.LocalPlayer.Backpack
	for i = 0.3, 1, 0.1 do
		wait(0.1)
		script.Parent.BackgroundTransparency = i
		script.Parent.Parent.BackgroundTransparency = i
		script.Parent.Parent.TextButton.BackgroundTransparency = i
	end
	script.Parent.Parent.Visible = false
	end
	
end

script.Parent.MouseButton1Click:connect(hi)

1 answer

✓ Accepted answer
wait(1)
button = script.Parent
local dbounce = false
function hi()
    if dbounce == false then
        dbounce = true
        script.Parent.Parent.TextButton.LocalScript:Destroy() -- Note this is destroying a different script
    `game.ServerStorage`.LinkedSword:clone().Parent = game.Players.LocalPlayer.Backpack
    `game.ServerStorage`.LinkedPaintballGun:clone().Parent = game.Players.LocalPlayer.Backpack
    for i = 0.3, 1, 0.1 do
        wait(0.1)
        script.Parent.BackgroundTransparency = i
        script.Parent.Parent.BackgroundTransparency = i
        script.Parent.Parent.TextButton.BackgroundTransparency = i
    end
    script.Parent.Parent.Visible = false
    end

end

script.Parent.MouseButton1Click:connect(hi)

ServerStorage is not accesible by the client. If you test it with studio Start Server and Start Player. The Player will see ServerStorage as an empty container but the server see's it correctly. Make sure that you put your tools in the ReplicatedStorage then.

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