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

I'm trying to make a script that gives you 1 leader stat when you sit on it, why wont it work?

Asked by 4 years ago

Line 16 is where the problem is

script:

-- Script should be inside the seat
local Seat = script.Parent
local Players = game:GetService("Players")

Seat:GetPropertyChangedSignal("Occupant"):Connect(function()
    --Get seat occupant
    local humanoid = Seat.Occupant

    --Check to make sure seat is not empty
    if humanoid == nil then return end

    --Get the player sitting in the seat
    local occupant = Players:GetPlayerFromCharacter(humanoid.Parent)

    --Get that player's seconds from the leaderboard
    local Money = Players[occupant].leaderstats.Money   

    --Increment their seconds on the leaderboard by 1 while sitting
    while Seat.Occupant == humanoid do wait(1)
        Money.Value += 1
    end
end)

2
I told you in the other post how to fix this, replace Players[occupant] with just occupant. The issue is that occupant is already a player object so you don't need to index it from Players. Sparks 534 — 4y
0
@Sparks is right. Block_manvn 395 — 4y
0
oh i forgot loll Script_Summary 13 — 4y

Answer this question