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

Output don't show me errors and script didn't work... Somebody help ? "specific title"

Asked by 5 years ago

My script didn't work properly and i don't know why. This is my script.

01local ItemId = script.Parent.ItemId
02local ItemName = script.Parent.ItemName.Value
03local ItemType = script.Parent.ItemType.Value
04local ItemValue = script.Parent.ItemValue.Value
05 
06ItemId.Changed:Connect(function(plr)
07    if ItemId.Value == 1 then
08        ItemName = "Katana"
09        ItemType = "Sword"
10        ItemValue = "n/a"
11    end
12end)

ItemName, ItemType and ItemValue are StringValues. ItemId is IntValue. Output don't show me any errors.

0
Put a print before the if statement and after it, then try manually setting the intvalue to 1 on the server. MachoPiggies 526 — 5y
0
Put a print before the if statement and after it, then try manually setting the intvalue to 1 on the server. MachoPiggies 526 — 5y
0
print("a") ItemId.Changed:Connect(function(plr) if ItemId.Value == 1 then ItemName = "Katana" ItemType = "Sword" ItemValue = "n/a" print("b") end end) Yakubovsky69 5 — 5y
0
only print "a" Yakubovsky69 5 — 5y
View all comments (3 more)
0
your code works fine. try changing the value of ItemID to 1. Fifkee 2017 — 5y
0
You forgot to add .Value after each one ya dumdum :D mixgingengerina10 223 — 5y
0
@mix Adding a .Value to them would just throw an error, because values don't have properties. I'm talking about values, not instances. Unhumanly 152 — 5y

1 answer

Log in to vote
0
Answered by
Unhumanly 152
5 years ago
Edited 5 years ago

I think I know what's going on here.

1local ItemName = script.Parent.ItemName.Value
2local ItemType = script.Parent.ItemType.Value
3local 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:

1ItemName.Value = "Weapon"
2ItemType.Value = "Gun"
3ItemValue.Value = 5

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.

01local ItemId = script.Parent.ItemId
02local ItemName = script.Parent.ItemName
03local ItemType = script.Parent.ItemType
04local ItemValue = script.Parent.ItemValue
05 
06ItemId.Changed:Connect(function(plr)
07    if ItemId.Value == 1 then
08        ItemName.Value = "Katana"
09        ItemType.Value = "Sword"
10        ItemValue.Value = "n/a"
11    end
12end)

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.

0
script still don't work Yakubovsky69 5 — 5y
0
Does the output display any errors? Unhumanly 152 — 5y
0
no ;( Yakubovsky69 5 — 5y
0
If this part of the script isn't running, then there's some other part of the script before this part that is preventing it from running. Unhumanly 152 — 5y
Ad

Answer this question