My script is returning an error in the output or in game console, but works perfectly fine.
The script I made checks if the player has a certain sword when touching a portal, and if they do, then it teleports them. If they don’t have the sword then it does not teleport them.
So my script works fine, however returns an error for some reason, here is an image of the error.
This won’t break anything, since events internally catch errors.
However, I think the problem is that Humanoid might not always exist depending on what hit the part, and you’re immediately trying to read from its Parent property. So if Humanoid doesn’t exist, how could that exist?
Here’s a better alternative:
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr then
--//do stuff
end
game.Workspace["Portal Island"].Portals["The Shattered Portal"].Teleporter.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr and plr:FindFirstChild("Shattered Portal Restorer", true) then
plr.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace["Shattered Portal Zone"].Teleporter.Position) + Vector3.new(0,3,0)
end
end)