Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is this local script not working?

Asked by
NecoBoss 194
9 years ago

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

Log in to vote
1
Answered by 9 years ago
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.

Ad

Answer this question