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

How to make a model not transparent when a part is hit?

Asked by 5 years ago

I tried using a local script on a part and it doesn't work. This script was supposed to make a person hallucinate and only that person who was affected by it can see the entity.

local plr = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
    if plr and debounce == false then
        debounce = true
        for i,v in pairs(workspace.Dummy:GetChildren())
            if v.ClassName == "Part" then
                v.Transparency = 0
            end
        end
    end
end)

It never really show any errors. I'm not sure what's wrong with it.

0
you can't use a local script with the touched function. p0vd 207 — 5y
0
So do I use a fire client event? marltonjohnson9876 11 — 5y
0
no use a script KDarren12 705 — 5y
0
game.Players.PlayerAdded:Connect(function(plr) will substitute for local player in a script KDarren12 705 — 5y

1 answer

Log in to vote
0
Answered by
KDarren12 705 Donator Moderation Voter
5 years ago

Put this in a SERVER SCRIPT(just "Script"), NOT a LOCAL SCRIPT!

game.Players.PlayerAdded:Connect(function()
plr = true
end)
script.Parent.Touched:Connect(function()
if plr and debounce == false then
debounce = true
for i,v in pairs(workspace.Dummy:GetChildren())
   if v.ClassName == "Part" then
v.Transparency = 0
end
end
end
end)

Sorry for the bad formatting, im on mobile and i needed to re-write the script.

Ad

Answer this question