I’m making a game where when you press a GUI button, whatever you typed in the textbox next to it spawns next to you. Right now I’m encountering an issue that spawns things next to the player who joined the server first rather than the player who clicked the button themselves.
local repstorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:wait()
local character = player.Character or player.CharacterAdded:wait()
local humroot = character:WaitForChild("HumanoidRootPart")
local RE = game.ReplicatedStorage.RemoteEvent
...
RE.OnServerEvent:Connect(function(plr, textInput)
if repstorage.Stuff:FindFirstChild(textInput) then
local model = repstorage.Stuff:FindFirstChild(textInput)
local modelclone = model:Clone()
modelclone.Parent = workspace
modelclone:PivotTo(humroot.CFrame)
modelclone:TranslateBy(Vector3.new(5, -1, 5))
else
...
end
end)