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

changing value not working? [EDITED]

Asked by 8 years ago

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

Log in to vote
0
Answered by
Kurieita 125
8 years ago

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.

0
Hmm doesnt seem to be working, the value number value isnt going up, any idea ghosteffectz 115 — 8y
Ad

Answer this question