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

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

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

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.

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