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

Why are my GUI updates only showing on server side?

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!

4 comments

0

Open and close the shop on the client. Purchases should be on the server

0

I don't understand what you mean

0

You're trying to make a shop right?

0

Oh, I understand what you mean now!

2 answers

✓ Accepted answer

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.

2 comments

0

"When a player wants to open the shop, do it on the client" Thank you, it's working now

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

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!

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