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

Why isn't this remote event not firing?

I'm trying to use a remote event to make a GUI appear on the screen of somebody who touches a button on the floor and then for it to be removed after a couple of seconds. The remote event itself can be found in ReplicatedStorage along with the receiving Script. None of the Scripts used are Localscripts as when I change the script inside of the button to a Localscript, absolutely nothing will happen - it doesn't even print the user you touched the button.

All help is appreciated.

-- Script inside the block to touch

local part = script.Parent
local debounce = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")

part.Touched:Connect(function(hit)
    if debounce == true then return end
    debounce = true
	print(hit.Parent.Name .. " has touched a part!")
	local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
	game.ReplicatedStorage.ShowGui:FireClient(Player)
	
	if Player and not Player.PlayerGui:FindFirstChild(Gui.Name) then
		Player.PlayerGui.MessageGui.Message.Alert.Text = "You Touched Me!"
	end		
    wait(5)
	Player.PlayerGui.MessageGui:Destroy()
    debounce = false
		end)

-- Script inside ReplicatedStorage

local player = game.Players.LocalPlayer
local Gui = game.ReplicatedStorage.MessageGui

game.ReplicatedStorage.ShowGui.OnClientEvent:connect(function(player)
	Gui:Clone().Parent = player.PlayerGui
	wait(3)
	player.PlayerGui.MessageGui:Destroy()
end)

1 answer

✓ Accepted answer

I couldn't help you if I wasn't in studio since I wasn't quite getting what you were doing, so I rescripted it.

--script inside part
local part = script.Parent
local db = false
part.Touched:Connect(function(hit)
	if db == false then
	db = true
	local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
	repeat wait() until hum
	local char = hum.Parent
	local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
	game.ReplicatedStorage.ShowGui:FireClient(plr)
	wait(5)
	db = false
	end
end)

and

--local script inside playergui
local plr = game.Players.LocalPlayer
local gui = game.ReplicatedStorage.ScreenGui

game.ReplicatedStorage.ShowGui.OnClientEvent:Connect(function()
	print(plr.Name)
	gui:Clone().Parent = plr.PlayerGui
	wait(3)
	plr.PlayerGui.ScreenGui:Destroy()
end)

When touched it showed you a gui, stays there for 3 secs and gets deleted. It has a 5 sec debounce. Edit the script as you wish.

13 comments

0

'Argument 1 missing or nil' when I remove the Player argument

0

keep the Player and tell me what happens

0

Then when I put it back in, it still won't fire

0

MessageGui is not a valid member of PlayerGui

0

Editted the asnwer, change the script I editted to the current one in local script.

0

MessageGui is not a valid member of PlayerGui, again

0

I am not sure if I can help you since I do not know the localization. I also do not have a perspective of the game.

0

At the moment I'm simply trying to get a part to show a GUI for the user who touched it and then for it to disappear after a few seconds but for whatever reason it won't show up at all

0

I rescripted everything, check my answer again.

0

How do you get the Localscript into PlayerGui?

0

Ahh StarterGui, that threw me off. Thank you.

0

No problem!

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