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

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

Asked by 5 years ago
Edited 5 years ago

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.

0
Make sure to accept Mythical's answer. User#19524 175 — 5y

2 answers

Log in to vote
2
Answered by 5 years ago

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)

0
well done mate stinkyest11 78 — 5y
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 :) MythicalShade 420 — 5y
0
im an absolute noob at this, i dont even know how to accept an answer stinkyest11 78 — 5y
0
There should just be a button that says "Accept Answer" MythicalShade 420 — 5y
View all comments (7 more)
0
probably only happens to you due to ur reputation mate stinkyest11 78 — 5y
0
No it happens on your question, however when you hit Accept Answer both of us get reputation. MythicalShade 420 — 5y
0
still doesnt work crap. do remote events work in playerGui? stinkyest11 78 — 5y
0
I believe they can(Not completely sure) but they do much better in ReplicatedStorage. MythicalShade 420 — 5y
0
yep everything isnt working.. stinkyest11 78 — 5y
0
This isn't working anymore? Was it not before? MythicalShade 420 — 5y
Ad
Log in to vote
-1
Answered by 5 years ago

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

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

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

0
Please remove this useless answer. MythicalShade 420 — 5y

Answer this question