Hello, I am trying to achieve a Carry System but whenever a player comes
Here is the full code:
local UI = script.Parent local RS = game:GetService("RunService") local debugmode = 0 local firstply = "nil" if debugmode == 0 then RS.Stepped:Connect(function() local ply = game.Players:GetPlayers() for i,v in pairs(ply) do if game.Players.LocalPlayer:DistanceFromCharacter(v.Character.UpperTorso.Position) <= 10 and v.Name ~= game.Players.LocalPlayer.Name and firstply ~= v.Name then firstply = v.Name print(game.Players.LocalPlayer.Name.." is close to "..firstply..".") script.Parent.Visible = true script.Parent.PlayerCarried.Text = ("Carry, "..firstply.."?") else if game.Players.LocalPlayer:DistanceFromCharacter(v.Character.UpperTorso.Position) >= 10 and v.Name ~= game.Players.LocalPlayer.Name and firstply == v.Name then firstply = "nil" print(game.Players.LocalPlayer.Name.." is not close to "..firstply..".") script.Parent.Visible = false end end end end) elseif debugmode == 0 then RS.Stepped:Connect(function() if game.Players.LocalPlayer:DistanceFromCharacter(game.Workspace.PlayerCarry.UpperTorso.Position) <= 10 then script.Parent.Visible = true else script.Parent.Visible = false end end) end UI.Carry.MouseButton1Click:Connect(function() game.ReplicatedStorage.CarryEvent:FireServer(firstply, game.Players.LocalPlayer.Name) print(firstply) end) UI.Cancel.MouseButton1Click:Connect(function() game.ReplicatedStorage.DropEvent:FireServer(firstply, game.Players.LocalPlayer.Name) print(firstply) end)
The code that is erroring is:
game.Players.LocalPlayer:DistanceFromCharacter(v.Character.UpperTorso.Position) <= 10 and v.Name ~= game.Players.LocalPlayer.Name and firstply ~= v.Name then
This is the errors I receive: https://i.imgur.com/peJUGUU.png https://i.imgur.com/vefPWWJ.png
This is the output it gives: https://i.imgur.com/beCK31M.png https://i.imgur.com/tuSAn8f.png
Sorry, if the Images are blurred.