Hi. I’m trying to get my head around RemoteEvents
and how they can be used to trigger a GUI change for all clients, however, as expected, I ran into an issue.
It’s worth noting that my scripting knowledge isn’t at all huge, so this is quite frustrating. Here’s a LocalScript
under StarterPlayerScripts
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateCrystals")
local plr = game.Players.LocalPlayer
local PPS = game:GetService('ProximityPromptService')
local ProximityPrompt = game.Workspace.proxPart1.ProximityPrompt
local proxPart = game.Workspace.proxPart1
local function onPromptTriggered(ProximityPrompt, plr)
proxPart:Destroy()
remoteEvent:FireServer()
end
PPS.PromptTriggered:Connect(onPromptTriggered)
I then placed a Script
inside ServerScriptService
, shown below
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateCrystals")
local plr = game.Players.LocalPlayer
local Crystal = game.Workspace.Crystal
local Crystal2 = game.Workspace.Crystal2
local startPos = Crystal.Position
local startPos2 = Crystal2.Position
local function moveCrystals()
task.spawn(function()
while (true) do
wait()
Crystal.Position = startPos + Vector3.new(0,math.sin(tick(), Enum.EasingDirection.In), 0)
Crystal2.Position = startPos2 + Vector3.new(0,math.sin(tick(), Enum.EasingDirection.In), 0)
end
remoteEvent:FireAllClients()
plr.PlayerGui.CrystalCounting.CrystalCountPrompt.CrystalCounter.Text = '1/4'
local prompt = plr.PlayerGui.CrystalMessagePrompts.CrystalPrompts.CrystalPrompt
plr.PlayerGui.CrystalMessagePrompts.CrystalPrompts.CrystalPrompt.Visible = true
prompt.AnchorPoint = Vector2.new(0, 0)
prompt.Position = UDim2.new(0.343, 0, 1, 0)
prompt:TweenPosition(UDim2.new(0.343, 0, 0.642, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quint)
plr.PlayerGui.CrystalMessagePrompts.CrystalPrompts.CrystalPrompt.Text = plr.Name .. ' activated a crystal!'
wait(3)
prompt:TweenPosition(UDim2.new(0.343, 0, 1, 0), Enum.EasingDirection.In, Enum.EasingStyle.Quint)
wait(5)
plr.PlayerGui.CrystalMessagePrompts.CrystalPrompts.CrystalPrompt.Visible = false
end)
end
remoteEvent.OnServerEvent:Connect(moveCrystals)
The actual crystals do what they’re supposed to do - which is to move. However, the actual GUI isn’t showing, or doing anything for that matter. The dev console isn’t showing any errors either, which is quite perplexing.
I’d be grateful for any help I can get. Thanks.