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

I don't know why the script is assuming this parameter as the touched part. '?'

Asked by 5 years ago
Edited 5 years ago
1local config = script.Configuration
2 
3game.Workspace.Part.Touched:Connect(function(player)
4    if player:GetPlayerFromCharacter() then
5        if player:GetRankInGroup(config.GroupId) >= config.Rank then
6            game.Workspace.Part:Destroy()
7        end
8    end
9end)

How might I make this script think the parameter as a player? (The script is inside the StarterCharacterScripts, if this may help.)

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

You are using the** touched** event and **GetPlayerFromCharacter() **incorrectly.

The Touched event doesn't pass a player it passes the part that touched that part

GetPlayerFromCharacter() -- Requires a potential character in it's paramaters

1.Touched:Connect(function(hit) -- Hit is the part that touched the part your listening for touch
2    local potentialPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
3    if potentialPlayer then -- Must be a player since it returned true
4        -- Then search for their rank etc
5    end
6end)

Also if this is meant to be client sided then it's completely pointless to even bother getting the player from the touched event.

If this helps an upvote or solve would be greatly appreciated.

  • Best Regards, - Syn
Ad
Log in to vote
0
Answered by 5 years ago
1game.Players.PlayerAdded:Connect(function(player)
2    game.Workspace.Part.Touched:Connect(function()     
3        if player then
4            if player:GetRankInGroup(886313) >= 1 then
5                game.Workspace.Part:Destroy()
6            end
7        end
8    end)
9end)
0
I'm sorry, that you feel I'm disrespecting you; but actually I forgot to put it in the StarterCharacterScripts and it didn't work, so I'll accept your answer. Really sorry. ISkyLordDoge 37 — 5y

Answer this question