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

Can anyone help me? Why doesn't the value change?

Can anyone help me and how to check if it's a number? ServerScript in ServerScriptService:

script.Parent.Event.Banken.OnServerEvent:Connect(function(player, what, val)
	if what == 5 then
		player.stats.Geld.Value = player.stats.Geld.Value-val
		player.stats.Bank.Value = player.stats.Bank.Value+val
	elseif what == "afhaal" then
		player.stats.Geld.Value = player.stats.Geld.Value+val
		player.stats.Bank.Value = player.stats.Bank.Value-val
	end
end)

Local script in a GUI:

local storten = script.Parent.Storten
local afhalen = script.Parent.Afhalen
local geld = script.Parent.geld
local updatetext = script.Parent.Wat
local banken = game.ReplicatedStorage.Events.Banken

function stort()
	local value = tonumber(script.Parent.geld.Text)
	local what = 5
	banken:FireServer(what, value)
	updatetext.Text = "Je hebt ".. value .." gestort."
	updatetext.Visible = true
	wait(5)
	updatetext.Visible = false
end

function afhaal()
	local value = tonumber(script.Parent.geld.Text)
	local what = "afhaal"
	banken:FireServer(what, value)
	updatetext.Text = "Je hebt ".. value .." afgehaalt."
	updatetext.Visible = true
	wait(5)
	updatetext.Visible = false
end

script.Parent.Close.MouseButton1Click:Connect(function()
	script.Parent.Parent:Destroy()
end)



storten.MouseButton1Click:Connect(stort)
afhalen.MouseButton1Click:Connect(afhaal)

1 answer

✓ Accepted answer

In the server script you're saying that the event is at script.Parent.Event.Banken, so that would mean that it's in the script's parent, which is ServerScriptService. However, in the local script you are saying that the event is at game.ReplicatedStorage.Events.Banken. It should be like this is the server script as well because the client cannot access ServerScriptService.

3 comments

0

A client can access ServerScriptService, only the contents will not be visible to the client.

0

Thanks for the correction.

0

Thx i didn't see it gg

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