#Why it only works in solo mode
It only works in studio solo mode since you're using a local script inside of a part, unless your part is a descendant of the player than it should work, but I highly doubt that! LocalScripts don't run if it isn't where is should be, it's like a script in ServerStorage, it won't run at all. The reason it works in studio is because, LocalScripts act like regular scripts in solo. This is to see if your script WOULD work. This is the reason that LocalScripts can use ServerStorage in solo but not in studio. But I mostly think that in solo you're all by yourself and in solo the whole game runs on client. That is the reason it is working in solo mode. I know this because in test mode 2 windows come up,
- The Studio where you're testing your game
- The SERVER
In solo mode there is no server that is being opened.
##Summary
Solo mode only runs on client side, there is not server since solo runs on client.
(I was surprised Goulstem didn't get this :)
#Script as a RegularScript
Use GetPlayerFromCharacter to get the player. You don't even need to get the player, all you need is the Character.
script.Parent.Touched:connect(function(part)
local h = part.Parent:WaitForChild("Humanoid")
if part.Parent:FindFirstChild("Shirt") then
part.Parent.Shirt:Destroy()
wait()
script.Parent.Search:Play()
h.WalkSpeed = 2
wait(5)
script.Parent.Search:Stop()
h.WalkSpeed = 16
Instance.new("Shirt", part.Parent).ShirtTemplate = "http://www.roblox.com/asset/?id=235795107"
end
end)
#Script as LocalScript
workspace.ShirtChanger.Touched:connect(function()
local char = game:GetService("Players").LocalPlayer.Character
wait()
char.Humanoid.WalkSpeed = 2
char.Shirt:Destroy()
workspace.ShirtChanger.Search:Play()
wait(5)
workspace.ShirtChanger.Search:Stop()
char.Humanoid.WalkSpeed = 16
Instance.new("Shirt", char).ShirtTemplate = "http://www.roblox.com/asset/?id=235795107"
end)
Hope it helps!
4 comments
Can't use LocalPlayer in an ordinary script. Look for the LocalScript object and use that.
Make sure that whatever code you're using "LocalPlayer" in is a localscript in somewhere like ReplicatedFirst, StarterPack, StarterGui
Nonononono. You're probably going to leave it in StarterPlayerScripts in the StarterPlayer folder, unless you're making a hopperbin or a gui or something. It would be helpful if you edited your question and added a script you made using LocalPlayer.
And there's that.