Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

1 answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.