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

Creating a FE on touch function script and it has an error..?

So I have created this script for filtering enabled and it's in a regular script in a part in the workspace, this should work because I used the method of Server to Client, in fact, it works without filtering enabled? I don't understand why Filtering Enabled breaks this when it's made specifically for it? Can anybody help me out?

local welcomePlayerEvent = Instance.new("RemoteEvent")
welcomePlayerEvent.Parent = game.ReplicatedStorage
welcomePlayerEvent.Name = "HenryShopEvent"
 
function onHit(hit)
	welcomePlayerEvent:FireClient(hit)
end
 
script.Parent.Touched:connect(onHit)

1 answer

✓ Accepted answer

Yeah here you go this is a fixed version:

see the problem was when your firing to the client you where sending it to a object other then the actual player.

Just did a update Try this:

Server:

local Players = game:GetService("Players") -- ignore

local welcomePlayerEvent = Instance.new("RemoteEvent")
welcomePlayerEvent.Parent = game.ReplicatedStorage
welcomePlayerEvent.Name = "HenryShopEvent"

function onHit(hit)
	local Player = Players:GetPlayerFromCharacter(hit.Parent)
    if Player then
        welcomePlayerEvent:FireClient(Player,'Welcome')

    end

end

script.Parent.Touched:connect(onHit)

Quick Client script i made :


local remote = game.ReplicatedStorage:WaitForChild('HenryShopEvent')
remote.OnClientEvent:connect(function(...)
	local Args = {...}
	if Args[1] == 'Welcome' then
		print('Welcome')
	end
end)

4 comments

0

This doesn't work, any other ideas?

0

oh sorry here one sec i forgot something

0

there try that.

0

Oml I love you it works :) I didn't realize the parenting was changed at first for the event for some reason

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