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

Make CanCollide local in FE Server?

Asked by 5 years ago

So,

I have the script

Regular Script:

script.Parent.Touched:Connect(function(part)
    print("a")
    if part.Parent:FindFirstChild("Humanoid") then
    print("b")
        local char = part.Parent
        local plr = game.Players:GetPlayerFromCharacter(char)
        print(plr.Name)

        if plr:GetRankInGroup(2810845) > 5 then
            print("c")
            script.Parent.CanCollide = false
        end
    end
end)

How do I make it so only the player who is allowed can walk trough? How to make the change local instead of global? Changing to local script does not work.

0
You could just use collisionGroups MythicalShade 420 — 5y
0
you could use a remote event stinkyest11 78 — 5y
0
Pedro another thing you could do is use a remoteevent and fireclient() to make the player do the change locally, as touched doesn't work from a local script. MythicalShade 420 — 5y
0
This would be much easier to accomplish with local parts, since there would be a different part for each player. This would allow you to change the properties of that part so it only impacts certain players. awfulszn 394 — 5y
0
That's what I'm suggesting by using the remoteevent. Collisiongroups aren't difficult and are MUCH easier if you know how to use them, but you can't use Touched from a local script so you'd need remoteevents to tell the client to make it non collidable MythicalShade 420 — 5y

2 answers

Log in to vote
0
Answered by
awfulszn 394 Moderation Voter
5 years ago

What you are attempting to do can easily be accomplished with local parts. A local part is a part that is only visible or interacted with by certain players. So you could essentially change the properties of this part to differ from the other players' part. Click here to learn more about local parts.

Note: Since local parts are not fully supported by Roblox, an update could be released at any moment that may break them.

Ad
Log in to vote
0
Answered by
hellmatic 1523 Moderation Voter
5 years ago

Server script:

--Insert a remote event in ReplicatedStorage named 'AccessEvent'
local AccessEvent = game.ReplicatedStorage:WaitForChild("AccessEvent")

script.Parent.Touched:Connect(function(part)
    print("a")
    if part.Parent:FindFirstChild("Humanoid") then
    print("b")
        local char = part.Parent
        local plr = game.Players:GetPlayerFromCharacter(char)
        print(plr.Name)

        if plr:GetRankInGroup(2810845) > 5 then
            print("c")
            AccessEvent:FireClient(plr, script.Parent) --- fires to the targeted player and sends the part
        end
    end
end)

Local script:

--Place this in StarterPlayerScripts located in the PlayerScripts folder
local AccessEvent = game.ReplicatedStorage:WaitForChild("AccessEvent")

AccessEvent.OnClientEvent:Connect(function(part)
    if part then 
        part.CanCollide = false 
    end
end)

Answer this question