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

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

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

local ItemId = script.Parent.ItemId
local ItemName = script.Parent.ItemName.Value
local ItemType = script.Parent.ItemType.Value
local ItemValue = script.Parent.ItemValue.Value

ItemId.Changed:Connect(function(plr)
	if ItemId.Value == 1 then
		ItemName = "Katana"
		ItemType = "Sword"
		ItemValue = "n/a"
	end
end)

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

7 comments

0

Put a print before the if statement and after it, then try manually setting the intvalue to 1 on the server.

0

Put a print before the if statement and after it, then try manually setting the intvalue to 1 on the server.

0

print("a") ItemId.Changed:Connect(function(plr) if ItemId.Value == 1 then ItemName = "Katana" ItemType = "Sword" ItemValue = "n/a" print("b") end end)

0

only print "a"

0

your code works fine. try changing the value of ItemID to 1.

0

You forgot to add .Value after each one ya dumdum :D

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.

1 answer

I think I know what's going on here.

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

ItemName.Value = "Weapon"
ItemType.Value = "Gun"
ItemValue.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.

local ItemId = script.Parent.ItemId
local ItemName = script.Parent.ItemName
local ItemType = script.Parent.ItemType
local ItemValue = script.Parent.ItemValue

ItemId.Changed:Connect(function(plr)
    if ItemId.Value == 1 then
        ItemName.Value = "Katana"
        ItemType.Value = "Sword"
        ItemValue.Value = "n/a"
    end
end)

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.

4 comments

0

script still don't work

0

Does the output display any errors?

0

no ;(

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.

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