Can anyone help me and how to check if it's a number? ServerScript in ServerScriptService:
1 | script.Parent.Event.Banken.OnServerEvent:Connect( function (player, what, val) |
2 | if what = = 5 then |
3 | player.stats.Geld.Value = player.stats.Geld.Value-val |
4 | player.stats.Bank.Value = player.stats.Bank.Value+val |
5 | elseif what = = "afhaal" then |
6 | player.stats.Geld.Value = player.stats.Geld.Value+val |
7 | player.stats.Bank.Value = player.stats.Bank.Value-val |
8 | end |
9 | end ) |
Local script in a GUI:
01 | local storten = script.Parent.Storten |
02 | local afhalen = script.Parent.Afhalen |
03 | local geld = script.Parent.geld |
04 | local updatetext = script.Parent.Wat |
05 | local banken = game.ReplicatedStorage.Events.Banken |
06 |
07 | function stort() |
08 | local value = tonumber (script.Parent.geld.Text) |
09 | local what = 5 |
10 | banken:FireServer(what, value) |
11 | updatetext.Text = "Je hebt " .. value .. " gestort." |
12 | updatetext.Visible = true |
13 | wait( 5 ) |
14 | updatetext.Visible = false |
15 | end |
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.