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

Value Triggered script not activated?

Asked by 6 years ago
Edited 6 years ago

Lines 25-29 not working when 10 players enter the game, any ideas why?

it should teleport the players to above their planes when Cars value is 10 or more

local DefinitelyPlane = workspace:FindFirstChild("1")
local PlaneName = 1
local Plane = workspace:FindFirstChild(PlaneName)
local PositionXX = 87.18
local PlayerQuantity = 0
local Full = false

if script.Cars.Value >= 10 then
    Full = true
end

game.Players.PlayerAdded:Connect(function(Player)
    print(Player.Name)
    PlayerQuantity = PlayerQuantity + 1
    if script.Cars.Value < 10 then 
     local RPlane = Plane:Clone() 
     script.Cars.Value = script.Cars.Value + 1
     PlaneName = PlaneName + 1
     PositionXX = PositionXX - 15
     RPlane.Parent = workspace
     RPlane.Name = PlaneName
     RPlane:MoveTo(Vector3.new(PositionXX, 5.1, -922.8))
     print("Not Enough Players")

     if script.Cars.Value > 9 then
     print("Enough Players! Starting Round...")
     local char = Player.Character or Player.CharacterAdded:Wait()
     local hrp = char:WaitForChild("HumanoidRootPart")
     hrp.CFrame = CFrame.new(PositionXX, 8.1 , -922.8)

end 
end
end)

3 answers

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

You messed up your if statement. You are checking if the Cars's value is greather than 9 only if it's lower than 10.

The statement should look like this:

local DefinitelyPlane = workspace:FindFirstChild("1")
local PlaneName = 1
local Plane = workspace:FindFirstChild(PlaneName)
local PositionXX = 87.18
local PlayerQuantity = 0
local Full = false

if script.Cars.Value >= 10 then
    Full = true
end

game.Players.PlayerAdded:Connect(function(Player)
    print(Player.Name)
    PlayerQuantity = PlayerQuantity + 1
    if script.Cars.Value < 10 then 
        local RPlane = Plane:Clone() 
        script.Cars.Value = script.Cars.Value + 1
        PlaneName = PlaneName + 1
        PositionXX = PositionXX - 15
        RPlane.Parent = workspace
        RPlane.Name = PlaneName
        RPlane:MoveTo(Vector3.new(PositionXX, 5.1, -922.8))
        print("Not Enough Players")
    elseif script.Cars.Value > 9 then
        print("Enough Players! Starting Round...")
        local char = Player.Character or Player.CharacterAdded:Wait()
        local hrp = char:WaitForChild("HumanoidRootPart")
        hrp.CFrame = CFrame.new(PositionXX, 8.1 , -922.8)
    end
end)

0
lemme try this SuperBeeperman 30 — 6y
0
Still not working SuperBeeperman 30 — 6y
Ad
Log in to vote
0
Answered by
Async_io 908 Moderation Voter
6 years ago

It looks like you perhaps misplaced your end? I'm not entirely sure on the purpose of your script. I would think that Kiriot would have gotten it, but I don't know. I'm just a lowly scripter.

Anywhos, here's the dealio.

local DefinitelyPlane = workspace:FindFirstChild("1")
local PlaneName = 1
local Plane = workspace:FindFirstChild(PlaneName)
local PositionXX = 87.18
local PlayerQuantity = 0
local Full = false

if script.Cars.Value >= 10 then
    Full = true
end

game.Players.PlayerAdded:Connect(function(Player)
    print(Player.Name)
    PlayerQuantity = PlayerQuantity + 1
    if script.Cars.Value < 10 then
     local RPlane = Plane:Clone() 
     script.Cars.Value = script.Cars.Value + 1
     PlaneName = PlaneName + 1
     PositionXX = PositionXX - 15
     RPlane.Parent = workspace
     RPlane.Name = PlaneName
     RPlane:MoveTo(Vector3.new(PositionXX, 5.1, -922.8))
     print("Not Enough Players")

     if script.Cars.Value > 9 then --This bad boy seems to be in your previous if statement?
     print("Enough Players! Starting Round...")
     local char = Player.Character or Player.CharacterAdded:Wait()
     local hrp = char:WaitForChild("HumanoidRootPart")
     hrp.CFrame = CFrame.new(PositionXX, 8.1 , -922.8)

end 
end
end)

You're basically saying

if script.Cars.Value < 10 then blah blah blah, script script if script.Cars.Value > 9 then

I'm not sure if this was intentional or if you forgot to put your end (for the if statement if script.cars.value < 10 prior to the if script.Cars.Value > 9.

If you're still confused, I don't know what to say buddy.

Review lines 23, 24, 31, and 32.

0
none of these is working just why? SuperBeeperman 30 — 6y
Log in to vote
0
Answered by 6 years ago

If you've followed the useful advice from above just try changing line 8 to read:

if script.Cars.Value > 10 then

It might not help but might as well give these things a go! :)

Answer this question