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

The tool giver script only works in solo mode, how do I fix it?

Asked by 7 years ago
Edited 7 years ago
local Gui = script.Parent
local player = game.Players.LocalPlayer
function sw()
    if Gui.Parent.Text == "Room is Fit"

        then
        Gui.Parent.Text = "You will recieve the key in a few seconds"
    wait(3)
    Gui.Parent.Text = "Room is checked out!"
    Gui.BackgroundColor3= Color3.new(170,0,0)
    game.ServerStorage.Flashlight:Clone()
    game.ServerStorage.Flashlight.Parent = player.Backpack
    player.Backpack.Flashlight.Name = "k"
    else
        Gui.Parent.Text = "Room is checked out!"
    end
    end

Gui.MouseButton1Down:connect(sw)


game.Players.PlayerRemoving:connect(function(player)
     if player.Backpack.Flashlight.Name == "k"
        then 
    Gui.Parent.Text = "Room is fit"
    Gui.BackgroundColor3= Color3.new(0,170,0)
    end
end)

1 answer

Log in to vote
1
Answered by
Suamy 68
7 years ago

If you are using a Normal Script, LocalPlayer will not work in the real Play mode. It only works in Test Mode because the client and server are joined.

Use a local script instead, and move it from ServerStorage to ReplicatedStorage, as LocalScripts cannot access ServerStorage.

0
I also suggest using WaitForChild for your tools. http://wiki.roblox.com/index.php?title=API:Class/Instance/WaitForChild Suamy 68 — 7y
0
Thank you funkennethmbah 30 — 7y
Ad

Answer this question