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

IntValue don't change it value when using remoteEvent?

This is the code I just write:

-Local script:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local randomNumber = math.random(1,10)

remoteEvent:FireServer(randomNumber)

-Server script:

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local intValue = workspace.IntValue.Value

local function changeValue(player, value)
	print(value)
	intValue = value
	print(intValue)
end

remoteEvent.OnServerEvent:Connect(changeValue)

The weird thing is output actually print the changed value of intValue, but when i check intValue in the explore window, it still 0.

Here is the screenshot:
-Output:
https://paste.pics/eeaf3eec649ad3e578e190bfd6a92b9c
-Properties:
https://paste.pics/30f0de1873278b16a71822fe765b7672
*Just copy and paste, the link tool is broken :/

Someone help me please!

2 comments

0

I sent an answer.

0

I’m so confused. Is intValue suppose to be the random number?

2 answers

✓ Accepted answer

local remoteEvent = game.ReplicatedStorage.RemoteEvent
local intValue = workspace.IntValue

local function changeValue(player, randomNumber)
    print(randomNumber)
    intValue.Value = randomNumber
    print(intValue.Value)
end

remoteEvent.OnServerEvent:Connect(changeValue)

Edit: Make sure the local script is in starterplayerscripts and the server script is in server script storage Also, I edited my script for it to work

6 comments

0

Mistype, i change the code.

0

Does it work?

0

Nope :/

0

What's it doing wrong after using raid6n's code? I don't really see any problems with the code.

0

We can’t fix his problem if we don’t know what his problem is.

0

Wait, I'm change the code when test the game, that why :/

You are trying to assign the value to the object instead of the property itself.

Line 06 in your server script.

It should be: intValue.Value = value

Also, this remote event is very easy to exploit. I know its a test remote but remember to add security measures at some point.

1 comment

0

Oh, i don't realize that. But that is still not the problem.

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