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

I'm trying to add if the player is in group, it will do this. I can't figure it out? [SOLVED]

Asked by 9 years ago

Can you add it for me? I can't figure out how to do it.

local debounce = false

function onTouch(hit)
if hit == nil then return end
if hit.Parent == nil then return end
if not game.Workspace:FindFirstChild("Home"..hit.Parent.Name) then
if game.Players:findFirstChild(hit.Parent.Name) ~= nil and debounce == false then
debounce = true
local b = script.Parent.Parent:Clone()
b.Parent = game.Lighting
b.Name = "Home"..hit.Parent.Name
wait(.4)
script.Parent.Parent.OwnerName.Value = hit.Parent.Name
script.Parent.Head:Remove()
script.Parent.Parent.Thing.Head.SurfaceGui.TextLabel.Text = "Home Owner: "..hit.Parent.Name
script.Parent.Parent.Parent.Name = "Home"..hit.Parent.Name
end
else
end
wait(3)
debounce = false
end

script.Parent.Head.Touched:connect(onTouch)

1 answer

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
9 years ago

Well, I'm presuming you want them to be in the group to get the house of some sort.

local debounce = false
local ID = 1337 -- Group ID

function onTouch(hit)
    if hit == nil then return end
    if hit.Parent == nil then return end
    if not game.Workspace:FindFirstChild("Home"..hit.Parent.Name) then
        if game.Players:findFirstChild(hit.Parent.Name) ~= nil and debounce == false and game.Players:GetPlayerFromCharacter(hit.Parent):IsInGroup(ID) then
            debounce = true
            local b = script.Parent.Parent:Clone()
            b.Parent = game.Lighting
            b.Name = "Home"..hit.Parent.Name
            wait(.4)
            script.Parent.Parent.OwnerName.Value = hit.Parent.Name
            script.Parent.Head:Remove()
            script.Parent.Parent.Thing.Head.SurfaceGui.TextLabel.Text = "Home Owner: "..hit.Parent.Name
            script.Parent.Parent.Parent.Name = "Home"..hit.Parent.Name
        end
            else
        end
    wait(3)
    debounce = false
end

script.Parent.Head.Touched:connect(onTouch)
0
Ah. Thanks. CoderOfTheMonth 0 — 9y
Ad

Answer this question