How do I access a player GUI through code?

I’m making an image that is a visualisation of player dash ability on a GUI (cooldown).
And someone said I need a remote event for this, so I made a script that sends signal from client to server, another script on server that sends it back, and script in a GUI that receives message from a server. That last one doesn’t work. It doesn’t even shows any errors.

First code:
image

local UserInputService = game:GetService("UserInputService") 
local replicatedstorage = game:GetService("ReplicatedStorage")
local DashQ = replicatedstorage:WaitForChild("DashQ")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local normalspeed = 80


dashbool = false
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
	if input.KeyCode == Enum.KeyCode.Q then
		if dashbool == false then
			DashQ:FireServer()
			dashbool = true
			humanoid.WalkSpeed = normalspeed * 2
			wait(5) --- How long will be active
			humanoid.WalkSpeed = normalspeed 
			wait(6) --- Cooldown
			dashbool = false
		end
	end
end)

Second one:
image

local replicatedstorage = game:GetService("ReplicatedStorage")
local DashQ2 = replicatedstorage:WaitForChild("DashQ2")

game.ReplicatedStorage.DashQ.OnServerEvent:Connect(function(player, CFrame)
	print("signal received server")
	DashQ2:FireClient(player)
	print("signal sent server")
end)

Last one (not receiveing any signal)
image

local replicatedstorage = game:GetService("ReplicatedStorage")
local button = script.Parent
local cooldown = script.Parent.cooldown

game.ReplicatedStorage.DashQ2.OnServerEvent:Connect(function(player, CFrame)
	print("Signal received Image ")
end)

And my remote events:
image

How to fix that?

This is simple, it is on the client meaning not the server. Your code should be:

local replicatedstorage = game:GetService("ReplicatedStorage")
local button = script.Parent
local cooldown = script.Parent.cooldown

game.ReplicatedStorage.DashQ2.OnClientEvent:Connect(function(player, CFrame)
	print("Signal received Image ")
end)
1 Like

Whoah, I went all out on a copy paste and missed one typo.
Thank you so much.

1 Like