RemoteEvent not being fired

Hello,

I have a button, that when touched, fires a RemoteEvent in replicated storage. There is another LocalScript which is the child of the RemoteEvent, that automatically translates it into a server event for another script that tweens a part to another position.

I have watched youtube tutorials, searched the devforum and even asked chatgpt which is notoriously unreliable for scripting and i could not resolve the issue, so i have turned back to posting on the devforum. Here are the scripts that i am referencing:

Button script:

activated = false

script.Parent.Hitbox.Touched:Connect(function(hit)
	if hit and hit.Parent and hit.Parent.Humanoid then
		game:GetService("ReplicatedStorage").ButtonActivated:FireAllClients(script.Parent.Name)
		script.Parent.Button.BrickColor = BrickColor.new("Lime green")
		activated = true
	end
end)

The localscript that is parented by the remote event:

script.Parent.OnClientEvent:Connect(function(args)
	print("button 1 was fired")
	task.wait()
	script.Parent:FireServer(args)
end)

finally, the part that checks for the server event and changes the cframe:

local stage = script.Parent.Parent.Parent
local UT = require(game:GetService("ReplicatedStorage").UTween)

game:GetService("ReplicatedStorage").ButtonActivated.OnServerEvent:Connect(function(args)
	print(args)
	if args == "Button1" then
		UT.TweenC(script.Parent, 1, Enum.EasingStyle.Bounce, CFrame.new(-11.067, 28.163, 33.316), Enum.EasingDirection.InOut, 0, false)
	end
end)

It would mean the world to me if this was solved, as i was silently breaking down from the inside trying to find what was wrong with the code (average roblox studio scripting experience)

1 Like

Is the touched event being triggered?

Try that:

script.Parent.Hitbox.Touched:Connect(function(hit)
	if hit then
       if hit.Parent:FindFirstChild("Humanoid") then
		 game:GetService("ReplicatedStorage").ButtonActivated:FireAllClients(script.Parent.Name)
		   script.Parent.Button.BrickColor = BrickColor.new("Lime green")
		   activated = true
        end
	end
end)

It was being triggered, but the event is not being fired.

Try the code I sent then and tell me if ti worked

it’s the same result with my script and your script

Try printing script.parent.Name

Go into testing and change to server side

Check if the localscript is being replicated

The script doesn’t run because it’s located inside ReplicatedStorage, scripts (including local scripts) can’t run in replicated storage unless you change some stuff, which I would suggest you don’t.

Though you can still fix this problem by just moving the script controlling the remoteEvent inside StarterPlayerScripts.

Other stuff to note,
don’t make one individual script control one individual remoteEvent, just make one script control all your remoteEvents, this’ll make organizing easier. Also make use of Folders, you can put a folder inside ReplicatedStorage and put remoteEvents inside that folder, again this is to just make things more organized.

2 Likes

Okay, this worked (with a few modifications to the handler script) but the main script isn’t working (the one that should check for the client fire). it doesnt move the part at all, and the arguments it provides are just the players name, not the button’s name as well. Thank you for the help though!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.