Why won't this script work? I have tried multiple methods to fix it. [ANSWERED]
Asked by
5 years ago Edited 5 years ago
Hello, I am trying to achieve a Carry System but whenever a player comes
Here is the full code:
01 | local UI = script.Parent |
02 | local RS = game:GetService( "RunService" ) |
07 | RS.Stepped:Connect( function () |
08 | local ply = game.Players:GetPlayers() |
09 | for i,v in pairs (ply) do |
10 | if game.Players.LocalPlayer:DistanceFromCharacter(v.Character.UpperTorso.Position) < = 10 and v.Name ~ = game.Players.LocalPlayer.Name and firstply ~ = v.Name then |
12 | print (game.Players.LocalPlayer.Name.. " is close to " ..firstply.. "." ) |
13 | script.Parent.Visible = true |
14 | script.Parent.PlayerCarried.Text = ( "Carry, " ..firstply.. "?" ) |
15 | else if game.Players.LocalPlayer:DistanceFromCharacter(v.Character.UpperTorso.Position) > = 10 and v.Name ~ = game.Players.LocalPlayer.Name and firstply = = v.Name then |
17 | print (game.Players.LocalPlayer.Name.. " is not close to " ..firstply.. "." ) |
18 | script.Parent.Visible = false |
24 | elseif debugmode = = 0 then |
26 | RS.Stepped:Connect( function () |
27 | if game.Players.LocalPlayer:DistanceFromCharacter(game.Workspace.PlayerCarry.UpperTorso.Position) < = 10 then |
28 | script.Parent.Visible = true |
30 | script.Parent.Visible = false |
35 | UI.Carry.MouseButton 1 Click:Connect( function () |
36 | game.ReplicatedStorage.CarryEvent:FireServer(firstply, game.Players.LocalPlayer.Name) |
40 | UI.Cancel.MouseButton 1 Click:Connect( function () |
41 | game.ReplicatedStorage.DropEvent:FireServer(firstply, game.Players.LocalPlayer.Name) |
The code that is erroring is:
1 | 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.