I asked someone, and they sent me on the right track. Still haven't figured this out.
local Player = game.player.Character local char = Player.Character or Player.CharacterAdded:Wait() local Button = script.Parent.FireButton function OnClicked() script.Parent:Destroy() print(Player.."Hit me D:") wait(.5) local FirePet = game.ReplicatedStorage.FirePet local xPosition = char.Torso.Position.X local yPosition = char.Torso.Position.Y local zPosition = char.Torso.Position.Z local function AddFirePet() local FirePetCopy = FirePet:Clone() FirePetCopy.Parent = char.Torso wait(1) FirePetCopy.Position = Vector3.new(xPosition,yPosition,zPosition) print("Reset Positions") end do AddFirePet() end end Button.MouseButton1Click:connect(OnClicked)
WARNING! You are using a local script, meaning that whatever you write there, will only be seen by the current player (client)! You should use RemoteEvents to create a client-server connection and replicate it to the server!
Documentation on RemoteEvents
And when using a LocalScript to get the current player you do game.Players.LocalPlayer
Fixing your code would be like:
local Player = game.Players.LocalPlayer local char = Player.Character or Player.CharacterAdded:Wait() local Button = script.Parent.FireButton function OnClicked() script.Parent:Destroy() -- This deletes the script's parent and it's children(including the script! Be careful!) print(Player.."Hit me D:") wait(.5) local FirePet = game.ReplicatedStorage.FirePet local xPosition = char.Torso.Position.X local yPosition = char.Torso.Position.Y local zPosition = char.Torso.Position.Z local function AddFirePet() local FirePetCopy = FirePet:Clone() FirePetCopy.Parent = char.Torso wait(1) FirePetCopy.Position = Vector3.new(xPosition,yPosition,zPosition) print("Reset Positions") end -- I removed "do", you do not use it to call functions! AddFirePet() end Button.MouseButton1Click:connect(OnClicked)