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

Why are my GUI updates only showing on server side?

Asked by 3 years ago

I'm trying to make a backpack/inventory shop similar to the one in Mining Simulator. I'm now trying to script exiting the shop, which I'm doing by firing a remote event. However, upon clicking the exit button, the ScreenGui updates on the server side but not the client side. I am scripting this in a local script located in ServerScriptService. Here's my local script:

exitbuttonevent = game.ReplicatedStorage.ExitButtonClicked
cam = workspace.CurrentCamera

local function exitbuttonclicked()
    local inventory = game.Players.LocalPlayer.PlayerGui:WaitForChild("inventory")
    inventory:WaitForChild("InventoryShopFrame").Visible = false
    inventory:WaitForChild("Storage"):WaitForChild("OpenInventory").Parent = inventory
    inventory:WaitForChild("Storage"):WaitForChild("inventorylabel").Parent = inventory
    inventory:WaitForChild("Storage"):WaitForChild("Shop").Parent = inventory
    cam.CameraType = Enum.CameraType.Custom
    cam.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
end

exitbuttonevent.OnServerEvent:Connect(exitbuttonclicked)

Can I have some help on this? Also, please ignore the camera stuff, if that doesn't work I'll test it later. I'm more worried about the GUI. Thank you!

0
Open and close the shop on the client. Purchases should be on the server MarkedTomato 810 — 3y
0
I don't understand what you mean PusheenicornGamerz 2 — 3y
0
You're trying to make a shop right? MarkedTomato 810 — 3y
0
Oh, I understand what you mean now! PusheenicornGamerz 2 — 3y

2 answers

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

You're confused with alot of stuff here. This is not an answer but it will help you understand more about RemoteEvents

  1. ServerScriptService is self explanatory it's just for Scripts or ModuleScripts.

  2. exitbuttonevent.OnServerEvent:Connect(exitbuttonclicked) I don't understand because you never fired a RemoteEvent. There are some examples at the bottom of the page.

  3. When a player wants to open the shop, do it on the client. When the player wants to purchase somthing do on a serverscript using a remote event.

Example:

LocalScript

TextButton.MouseButton1Click:Connect(function() -- when a player clicks a button on the client
   remoteEvent:FireServer(PriceOfTool) -- sends a signal to the server with an argument priceOfTool
end)

ServerScript

remoteEvent.OnServerEvent:Connect(function(client, PriceOfTool) --[[ we have the PriceOfTool parameter since we sent the price to the server. The client parameter is by default whenever OnSeverEvent is fired we get the player that fired it.]]
   local leaderstats = client.leaderstats
   if leaderstats.Cash.Value >= PriceOfTool then
      Tool:Clone().Parent = client.Backpack    
      leaderstats.Cash.Value = leaderstats.Cash.Value - PriceOfTool
   end
end)

Anymore questions? Just reply below.

0
"When a player wants to open the shop, do it on the client" Thank you, it's working now PusheenicornGamerz 2 — 3y
0
Also, thank you for the information, I'm not that good with scripting and I'm trying to teach myself so new knowledge is really valuable! Thank you for your help PusheenicornGamerz 2 — 3y
Ad
Log in to vote
-1
Answered by 3 years ago
exitbuttonevent = game.ReplicatedStorage.ExitButtonClicked
cam = workspace.CurrentCamera

local function exitbuttonclicked()
    local inventory = game.Players.LocalPlayer.PlayerGui:WaitForChild("inventory")
inventory:WaitForChild("InventoryShopFrame").Visible = false
    inventory:WaitForChild("Storage"):WaitForChild("OpenInventory").Parent = inventory
    inventory:WaitForChild("Storage"):WaitForChild("inventorylabel").Parent = inventory
    inventory:WaitForChild("Storage"):WaitForChild("Shop").Parent = inventory

cam.CameraType = Enum.CameraType.Custom

end dont use onserver event because it on server side!

Answer this question