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

Whats wrong in line 6?

Got this error message

23:58:47.299 - Players.Player.PlayerGui.KnifeScript:6: attempt to index field 'Value' (a number value) 23:58:47.302 - Stack Begin 23:58:47.303 - Script 'Players.Player.PlayerGui.KnifeScript', Line 6 23:58:47.303 - Stack End

For this script:

while wait() do
	player = game.Players.LocalPlayer
	leaderstats = player:WaitForChild("leaderstats")
	Spree = leaderstats:WaitForChild("Spree")
	SHS = leaderstats:WaitForChild("Spree HS")
	Spree.Value.Changed:connect(function(prop)
		if Spree.Value >= SHS.Value then
			SHS.Value = Spree.Value
		end
	end)
end

2 comments

2

Properties do not have events, all you would need to do is remove .Value from line 6 then the script will know that the object has events and fire if the property has changed.

0

Great. Thanks!

1 answer

✓ Accepted answer

Try this as a fix!

while wait() do
    player = game.Players.LocalPlayer
    leaderstats = player:WaitForChild("leaderstats")
    Spree = leaderstats:WaitForChild("Spree")
    SHS = leaderstats:WaitForChild("Spree HS")
    Spree.Changed:connect(function(prop)
	if prop == "Value" then
	        if Spree.Value >= SHS.Value then
	            SHS.Value = Spree.Value
	        end
	end
    end)
end

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