My number value doesn't change whenever the script runs through it. The change is at line 38.
001 | local UserInputService = game:GetService( "UserInputService" ) |
002 | local doors = game.Workspace.Doors:GetChildren() |
003 | local player = game.Players.LocalPlayer |
004 | local slow = 0 |
005 |
006 | local function onInputBegan(InputObject, gameProcessedEvent) |
007 | for i , v in pairs (doors) do |
008 | local open = v.open.Value |
009 | if math.ceil((v.Part.Position - player.Character.Head.Position).Magnitude) < = 10 then |
010 | if InputObject.KeyCode = = Enum.KeyCode.E and open = = 0 then |
011 | local doormodel = v |
012 | v = doormodel |
013 | local door = doormodel.Part |
014 | local X = door.Position.X |
015 | local endX = X - 2.9 |
I would like to elaborate on what Killerbot72 said, except you can change values from a local script. But if you get the value on the server, it will return something else.
Your issue is that on line 8, you said the following:
1 | local open = v.open.Value |
This code returned the current value, not the actual object. By this I mean you were just changing the variable, so when you said this:
1 | open = open + 1 |
You weren't adding on the value's value. You were adding to number variable that wasn't changing anything else.
The fix is that on line 8, put:
1 | local open = v.open |
And then, on line 38, put:
1 | open.Value = open.Value + 1 |
If you refrenced open anywhere else in the script, make sure you are doing your comparisons using open.Value, not open
Hope this helped!
You can't change values with a local script by itself. So you MUST use remote events
this might help
for example if you wanted to change a value when a player clicks a textbutton you will have to put a RemoteEvent in ReplicatedStorage.
and in the local script inside of the text button you would have to write
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 |
3 | game.ReplicatedStorage.RemoteEvent:FireServer() |
4 |
5 |
6 | end ) |
and then in a server script you would write
1 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect( function (player) |
2 | player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1 |
3 | end ) |