I need to access the player that clicks a block block. I also need to access the player who's mouse hovers over a block. My code only works in studio.
workspace.ChangeOutfit.ClickDetector.MouseClick:connect(function(changeOutfit) local pz=game.Players.LocalPlayer.Character:GetChildren() for i=1,#pz do if pz[i].className=="Shirt" then pz[i]:Destroy() end end local shirt = Instance.new("Shirt") shirt.Parent = game.Players.LocalPlayer.Character shirt.Name = "NewOutfit" shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=332017894" end)
This works in studio but not on a game server.
script.Parent.Parent.ClickDetector.MouseHoverEnter:connect(function(ShowClothingGui) Gui = script.Parent.Clothing:Clone() Gui.Parent = game.Players.LocalPlayer.PlayerGui end) script.Parent.Parent.ClickDetector.MouseHoverLeave:connect(function(HideClothingGui) Gui:Destroy() end)
The same with this code.
Thanks for your help.
workspace.ChangeOutfit.ClickDetector.MouseClick:connect(function(player) -- has a parameter pre-set to return player as a parameter local pz=player.Character:GetChildren() for i=1,#pz do if pz[i].className=="Shirt" then pz[i]:Destroy() end end local shirt = Instance.new("Shirt") shirt.Parent = player.Character -- Edited to change this didnt see it sry .-. shirt.Name = "NewOutfit" shirt.ShirtTemplate = "http://www.roblox.com/asset/?id=332017894" end)
http://wiki.roblox.com/index.php?title=API:Class/ClickDetector
You can't access the Client from the server, However, but you can get the player that clicked the ClickDetector because it takes a parameter for the player.