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

changing value not working? [EDITED]

I'm trying to make it so when the player scrolls up the values will go up by 1, but nothing happens.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local num = script.Parent.Scrollnum.Value

Mouse.WheelForward:connect(function()
	num = num +1
end)

Mouse.WheelBackward:connect(function()
end)


1 answer

I ran into this problem when I was first learning how to script.

By saying the following, you're assigning 'num' a number, not the actually Scrollnum.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local num = script.Parent.Scrollnum.Value

Mouse.WheelForward:connect(function()
    num = num +1
end)

Mouse.WheelBackward:connect(function()
end)

Meaning,

num = script.Parent.Scrollnum.value

Is the exact same thing as

num = 5

This is a simple fix.

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local num = script.Parent.Scrollnum

Mouse.WheelForward:connect(function()
    num.Value = num.Value +1
end)

Mouse.WheelBackward:connect(function()
end)

I don't know how to explain it any other way. Please thumb up if this helped.

1 comment

0

Hmm doesnt seem to be working, the value number value isnt going up, any idea

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