Well, first off
that is not how you use pcall.
Whenever you call a pcall function you need 2 arguments, they can be named whatever (I think), but mostly people just do success, and error
so how to do to a pcall
function Good()
print("hi")
end
local suc, err = pcall(Good)
if suc then
end
Now, looking at your code, it looks like you have no reason for a pcall (correct me if I'm wrong)
P.S
you don't need 'mouse' as an argument.
If you are doing this with a gui, having another click function is pointless
[EDIT]
So LoadCharacter only works on the server.
How can we fix it?
Remote events!
Create a remote event and place it in RemoteStorage
Name it whatever, and put the server script wherever?
Inside the script, put this
local re =
re.OnServerEvent:connect(function(player)
local Pos = plr.Character:GetPrimaryPartCFrame()
player:LoadCharacter()
player.Character:SetPrimaryPartCFrame(Pos)
if player.Character:FindFirstChild("ForceField") then
player.Character["ForceField"]:Destroy()
end
end)
Inside the local script put
plr = game.Players.LocalPlayer
local re =
script.Parent.MouseButton1Click:connect(function()
re:FireServer()
end)
Helpful? Make sure to accept this answer!
Comments? Questions? Concerns?
Make sure to ask!
Did I get anything wrong?
Please don't hate, just tell me!
sources
Pcall information
1 comment
It doesn't print anything cuz pcall would catch any errors. You'd have to do: local a,b = pcall(function() -stuff- end) if not a then warn b end