Hi! I have made a script. It works perfectly fine in play solo, but when I do a server test or I upload it to ROBLOX and play it, either an error is returned or it does not work. Firstly, here is the script. I want it to give the player a sword, then teleport them into the map.
local button = script.Parent
local player = game.Players.LocalPlayer
function teleport()
player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(0,50,0))
end
function givetool()
game.ServerStorage.Weapons.ClassicSword:Clone().Parent = game.Players.LocalPlayer.Backpack
print(player, "has been given a sword")
teleport()
end
button.MouseButton1Click:connect(givetool)
I originally had this in a localscript. When I did play solo, it worked perfectly fine. When I upload it to ROBLOX or I do a server test, it does one of two things:
- If it is in a localscript, the output shows a blank message.
- If it is in a regular script, the output shows that it is it's trying to index a nil value (LocalPlayer)
I'm not sure how I can fix this. I believe I'm trying to mix parts that only work in a local script with parts that only work in a regular script, but I just can't figure this one out. Can anybody provide me with help?

1 comment
Thanks so much! You explained everything clearly and what you suggested work.