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

how can i refrence a player s characther in a local script?

Asked by 3 years ago

OH AND how can i make a part that takes cash or someting

1 answer

Log in to vote
0
Answered by 3 years ago

Getting the Character:

local player = game.Players.LocalPlayer
local char = player.Character

--to get part of the character:
local part = char:WaitForChild("UpperTorso") 

Reminder:

  1. Lua is Case Sensitive

  2. "WaitForChild" is important so there won't be any nil

Money Taking Script:

There are better tutorials online. This is the simple way.

local player = game.Players.LocalPlayer --getting the local player
local moneyVal = Instance.new("NumberValue", player) --making the number value to store
moneyVal.Name = "Cash" --name it to something so you can find it in the player tree
moneyVal.Value = 1000 -- starting value

while true do --loop to decrease it
    wait(1)
    moneyVal.Value -= 1 --this is main one; subtracts 1 from the value
end

Hope this Helps!

Ask me if you have any questions!

Ad

Answer this question