Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
This doesn't work, any other ideas? greybird700 63 — 6y
0
oh sorry here one sec i forgot something advancedev 70 — 6y
0
there try that. advancedev 70 — 6y
0
Oml I love you it works :) I didn't realize the parenting was changed at first for the event for some reason greybird700 63 — 6y
Ad

Answer this question