I’m pretty new at scripting and I’m trying to make a GUI button that refreshes the player’s appearance but it seems to not be working. I checked the output and this is what it says…
Images:
Script:
script.accept.MouseButton1Click:connect(function(plr)
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
if plr.Character then
plr.Character:SetPrimaryPartCFrame(Pos)
end
end)```
script.Parent.MouseButton1Click:Connect(function(plr)
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
if plr.Character then
plr.Character:SetPrimaryPartCFrame(Pos)
end
end)
Using script.Accept assumes that the button is inside the script. Since the script is parented to the button, you want to use script.Parent
local plr=game:GetService('Players').LocalPlayer
script.Parent.MouseButton1Click:connect(function()
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
if plr.Character then
plr.Character:MoveTo(Pos)
end
end)
@jrdonat was right, you can’t use LoadCharacter on the client
I tried again, hopefully this is an improvement
-- Server script
local plr = script.Parent.Parent.Parent.Parent.Parent
script.Parent.MouseButton1Click:Connect(function()
local Pos = plr.Character:GetPrimaryPartCFrame()
plr:LoadCharacter()
if plr.Character then
plr.Character:MoveTo(Pos)
print('refreshed')
end
end)