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

I am trying to make a seat that gives 1 money when you sit on it, why no work?

Asked by 4 years ago
Edited 4 years ago

This script is by someone named "sparks" yuh
Update: On output when "I sit on the seat it says " 20:37:19.022 - Workspace.Seat.Script:16: invalid argument #2 (string expected, got Instance)"

and "20:40:20.735 - Stack Begin 20:40:20.738 - Script 'Workspace.Seat.Script', Line 16 20:40:20.739 - Stack End"

-- 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)

0
Is there an error? Sparks 534 — 4y
0
No Script_Summary 13 — 4y
0
wait lemm check Script_Summary 13 — 4y
0
yes it says " 20:37:19.022 - Workspace.Seat.Script:16: invalid argument #2 (string expected, got Instance)" when i sat on the seat Script_Summary 13 — 4y
View all comments (4 more)
0
Oh right, I forgot to index the Name property. I updated the code. Sparks 534 — 4y
0
If you didn't read the update, change Players[occupant] to just occupant.leaderstats.Money. Sparks 534 — 4y
0
k ill try it Script_Summary 13 — 4y
0
OMG UR THE BEST TYSM Script_Summary 13 — 4y

Answer this question