Answered by
5 years ago Edited 5 years ago
I think I know what's going on here.
1 | local ItemName = script.Parent.ItemName.Value |
2 | local ItemType = script.Parent.ItemType.Value |
3 | local ItemValue = script.Parent.ItemValue.Value |
These three lines appear the be the reason this isn't working properly.
You seem like you want to set the variables ItemName, ItemType, and ItemValue to the Value property of the Values, so you can access these values quicker and type less.
What you're actually doing is setting these variables to the value of those values.
Let's assume the following:
1 | ItemName.Value = "Weapon" |
You're setting ItemName, ItemType, and ItemValue to be equal to "Weapon", "Gun", and 5, respectively.
You're referencing Values when using these variables, not Instances.
Here's the revised version of the script.
01 | local ItemId = script.Parent.ItemId |
02 | local ItemName = script.Parent.ItemName |
03 | local ItemType = script.Parent.ItemType |
04 | local ItemValue = script.Parent.ItemValue |
06 | ItemId.Changed:Connect( function (plr) |
07 | if ItemId.Value = = 1 then |
08 | ItemName.Value = "Katana" |
09 | ItemType.Value = "Sword" |
10 | ItemValue.Value = "n/a" |
Also, you put "plr" as a parameter for the .Changed listener.
The .Changed event, when fired, returns the property that was changed, not a player.