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

Server script not being cooperative and not printing player intvalue correctly? please help.

Asked by 4 years ago

In a localscript i have a remote event that fires to the server, remote events automatically make the player the first parameter so the script on the servers side has the player. However, when i run these scripts below:

local lvlup = game:GetService("ReplicatedStorage"):WaitForChild("RE"):WaitForChild("lvlup")
local lvlupreturn = game:GetService("ReplicatedStorage"):WaitForChild("RE"):WaitForChild("lvlupreturn")

local player = game.Players.LocalPlayer
local leaderboard = player:WaitForChild("leaderboard")
local XP = leaderboard.XP
local Lvl = leaderboard.Lvl
local XPreq = Lvl.Value*100

local function set()
value.Text = XP.Value .. " / " .. XPreq
script.Parent.Size = UDim2.new(XP.Value/XPreq,0,1,0)
end

local player = game.Players.LocalPlayer
local leaderboard = player:WaitForChild("leaderboard")
local XP = leaderboard.XP

local debounce = true

local function levelup()
    if debounce == true then
        debounce = false
        lvlup:FireServer()
        end
        lvlupreturn.OnClientEvent:Connect(function()
        set()
        debounce = true
    end)
end

XP:GetPropertyChangedSignal("Value"):Connect(function()
    levelup()
end)

Server

local lvlup = game:GetService("ReplicatedStorage"):WaitForChild("RE"):WaitForChild("lvlup")
local lvlupreturn = game:GetService("ReplicatedStorage"):WaitForChild("RE"):WaitForChild("lvlupreturn")

lvlup.OnServerEvent:Connect(function(player)
local XP = player.leaderboard.XP
print(XP.Value)
lvlupreturn:FireClient(player)
end)

The server script always prints XP.Value as 0 even when it isnt

0
it appears that there is no change occuring to the XP variable from scripts, is there some other way you are modifying it? theking48989987 2147 — 4y
0
i changed it by going to the intvalue manually and changing it Wiggles1305 49 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

"i changed it by going to the intvalue manually and changing it"

If you test play solo in Roblox Studio, Roblox is simulating both the server and client - you start out seeing thing as the client, so changing the XP's value will be filtered -- the server won't see it. Click on the Client/Server toggle before making your changes and they will be properly replicated.

Ad

Answer this question