Hello, fellow Lua users. I am quite new to Roblox scripting and I would want to ask you how can you find a player that clicked an object. For example, I tried this method: ...MouseButton1Down:connect(function(plr) plr = game.Players:FindFirstChild(plr). This did not really work out.
script.Parent.ClickDetector.MouseClick:connect(function(c) local plr = game.Players:FindFirstChild(c) if plr.PlayerGui.CarName.Value == "power" then script.Parent.Material = "SmoothPlastic" local clone = game.ServerStorage["2011 F-250 Super Duty 6.7L Power Stroke"]:Clone() clone.Parent = game.Workspace end end)
I hope this question was understandable enough with my lack of English.
As luke said, 'c' would be the player. So FindFirstChild() to get the player is useless, as the player is 'c'. I would say the error is with 'local plr = game.Players:FindFirstChild(c)' The argument for FindFirstChild() is a string, and you are feeding it an object. Other than that, seems fine.
Using FindFirstChild
is completely useless as MouseClick
returns the player object located under game.Players