When I click a textbutton, I want "Koenigsegg One:1" to clone into workspace and hover over the player that click the button head, it does not clone though.
script.Parent.MouseButton1Click:connect(function() game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function(char) local C = game.ReplicatedStorage.Cars:WaitForChild("Koenigsegg One:1"):Clone() C.Parent = game.Workspace C:MoveTo(char.HumanoidRootPart.Position + Vector3.new(3, 0, 3)) end) end) end)
Thanks if you help me :)
This is a GUI, you use localscripts for GUIs. Make your script a local script then use the script bellow, under the script is the explanation.
local plr = game.Players.LocalPlayer repeat wait() until plr.Character -- wait for player to not be nil, then make the variable of it bellow local char = plr.Character script.Parent.MouseButton1Click:connect(function() local C = game.ReplicatedStorage.Cars:WaitForChild("Koenigsegg One:1"):Clone() C.Parent = game.Workspace C:MoveTo(char.HumanoidRootPart.Position + Vector3.new(3, 0, 3)) end)
You were using Events in an event in an event, two of which (PlayerAdded/CharacterAdded) wouldn't fire just because you press the button. I'm not even sure what would happen. Comment any questions if you need further explanations or errors occur!
Using localscripts would speed up things..