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

Why is the TaxValue changing into 0?

Asked by 5 years ago

Script in ServerScriptService

game.ReplicatedStorage.Main.Events.TaxValueChange.OnServerEvent:connect(function(plr)
    local amountB = plr.PlayerGui.HUD.TaxFrame.Frame.Amount

    wait(.5)
    plr:WaitForChild("Tax").Value = amountB.Text

end)

LocalScript in a button

script.Parent.MouseButton1Click:connect(function(n)
    local amount = script.Parent.Parent.Amount
    local event = game.ReplicatedStorage.Main.Events.TaxValueChange
    event:FireServer("TaxThoseDuds",0)
end)

Im using a TextBox to change the value of how much taxing is

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
5 years ago

Scripts do not have access to objects in the PlayerGui. Instead of reading the value on the server, it should be passed as an argument by the LocalScript:

event:FireServer(tonumber(player.PlayerGui.HUD.TaxFrame.Frame.Amount))
0
Actually they do have access if they take in player as a parameter. TiredMelon 405 — 5y
0
Isn't changing the value at all just the same problem is occurring. SamthekidRSsl 58 — 5y
Ad

Answer this question