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

Why wont this point detecting script work? i need it for a coin system.

Asked by 6 years ago

Here is the script

~~ if game:GetService("Players"):GetPlayerFromCharacter(touchedPart.parent)then Instance.new("IntValue") Instance.new("IntValue").Parent = Coins Instance.new("IntValue").Value = 0 if game:GetService("Players"):GetPlayerFromCharacter(touchedPart.Parent).leaderstats.Coins.Value = 20 then end end ~~

1 answer

Log in to vote
0
Answered by
mattscy 3725 Moderation Voter Community Moderator
6 years ago

Remember to format your scripts in a lua block, it can be difficult to read without it.

From what I can see, you are creating new IntValues every time you use Instance.new, instead of changing the properties of the original one. To fix this, you have to create a variable that you will use to refer to your new IntValue, and use that variable to change the properties of the value. In this example, the variable name used to refer to the IntValue is NumCoins:

local NumCoins = Instance.new("IntValue")
NumCoins.Parent = Coins
NumCoins.Value = 0

Keep in mind this is assuming you have created a variable called Coins that you will put the value inside of when you set its parent.

Ad

Answer this question