Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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:

01local UI = script.Parent
02local RS = game:GetService("RunService")
03local debugmode = 0
04local firstply = "nil"
05if debugmode == 0 then
06 
07RS.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
11            firstply = v.Name
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
View all 43 lines...

The code that is erroring is:

1game.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.

0
do u use r6? HappyTimIsHim 652 — 5y
0
I'm using R15. iiMxtt_Destinyii 62 — 5y
1
why is firstply a string? if you want to assign it's really nil, you should remove the quotation marks. also, pretty sure what's wrong is the "(v.Character.UpperTorso.Position) <= 10", because you haven't specified the axis (x,y,z) Goomiin 1 — 5y
0
Alright, that seemed to fix it. Thanks for the help. iiMxtt_Destinyii 62 — 5y
0
If it is fixed, you should put [Answered] in the question title so people know. CoolOlivie057 45 — 5y

Answer this question