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

How could I make this script find the correct cash?

Asked by 10 years ago
01model = script.Parent.Parent.Model
02price = 100
03blarg = script.Parent.Parent.Name
04copy = model:Clone()
05wait(1)
06model:Destroy()
07Owner = script.Parent.Parent.Parent.Owner
08local safety = 0
09function onTouched(hit)
10    if safety == 0 then
11        safety = 1
12        check = hit.Parent:FindFirstChild("Humanoid")
13        if check ~= nil then
14            if hit.Parent.Name == Owner.Value then
15                --------------------------------- Here's the problem----------
View all 36 lines...

The problem here is that when a player joins the game I create a new NumberValue in a model called Cash in Workspace. The NumberValue's name is their name. How would I get it to check the NumberValue with their name when it checks how much money they have? I selected the area in the script where I tried to make it work.

0
If 'guy' is a value, you would do             local cash = Workspace.Cash.guy.Value Tempestatem 884 — 10y
0
Any errors? Also, on line 19 try 'if cash.Value >= price then' and line 25 try 'elseif cash.Value <= price then'. GoldenPhysics 474 — 10y

1 answer

Log in to vote
1
Answered by
TopDev 0
10 years ago

Here you go, let me know if it works.

** Edit :

I noticed I had cash instead of Cash - Fixed **

01model = script.Parent.Parent.Model
02price = 100
03blarg = script.Parent.Parent.Name
04copy = model:Clone()
05wait(1)
06model:Destroy()
07Owner = script.Parent.Parent.Parent.Owner
08local safety = 0
09function onTouched(hit)
10    if safety == 0 then
11        safety = 1
12        check = hit.Parent:FindFirstChild("Humanoid")
13        if check ~= nil then
14            if hit.Parent.Name == Owner.Value then
15                --------------------------------- Here's the problem----------
View all 36 lines...
0
Worked! Awesome man! jaytheidiot 60 — 10y
Ad

Answer this question