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

I used a remote event to change the players values, but it only works in studio? [SOLVED]

this is a part of the local script:

local found = game:GetService("Players").LocalPlayer:FindFirstChild("Backpack")
	if found then
		script.Parent.RemoteEvent:FireServer()

this is the regular script:

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	game.Players.LocalPlayer.Backpack.Values.Level.Value = 1
	game.Players.LocalPlayer.Backpack.Values.PlayedValue.Value = 1
	
end)

works perfect in studio but in the actual game it still acts like a local script or it doesnt work at all. no errors appear.

1 comment

0

Make sure to accept Mythical's answer.

2 answers

✓ Accepted answer

Your problem is that you cannot access LocalPlayer through a server side script.

However, when you use FireServer() the player is automatically sent to the server side script. So to fix this, just change your regular script to this.

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player) 
   player.Backpack.Values.Level.Value = 1
   player.Backpack.Values.PlayedValue.Value = 1
end)

11 comments

0

well done mate

0

Did it work? If so you should accept the answer or put [Solved] in the title so people know there is no longer an issue. And glad to help :)

0

im an absolute noob at this, i dont even know how to accept an answer

0

There should just be a button that says "Accept Answer"

0

probably only happens to you due to ur reputation mate

0

No it happens on your question, however when you hit Accept Answer both of us get reputation.

0

still doesnt work crap. do remote events work in playerGui?

0

I believe they can(Not completely sure) but they do much better in ReplicatedStorage.

0

yep everything isnt working..

0

This isn't working anymore? Was it not before?

Aaaaaaa~~~~~~~~~~~~~~~~~


~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~

1 comment

0

Please remove this useless answer.

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