So say there was a door. The door was like VIP. He didn't have the pass and he would die. How do I do that?
COMMUNITY QUESTION
How do I change the property of a local player's health?
3 answers
texture = "Texture of the Tshirt"
local Door = script.Parent
function onTouched(hit)
print("Door Hit")
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil ) then
if human.Parent.Torso.roblox.Texture == texture then
Door.Transparency = 0.7
Door.CanCollide = false
wait(However Many Secs you want to stay open)
Door.CanCollide = true
Door.Transparency = 0
else
human.Health = 0
end
end
end
script.Parent.Touched:connect(onTouched)
There, put this under the door.
Why don't just do this?:
local shirt = "id of your shirt"
local player = game.Players.LocalPlayer
local door = script.Parent
function onTouch(part)
if player.Character.Humanoid.Torso.Texture == shirt then
door.Transparency = 0.7
door.CanCollide = false
wait(2) -- Wait 2 seconds before blocking again the door
door.Transparency = 0
door.CanCollide = true
else
player.Character.Humanoid.Health = 0
end
end
door.Touched:connect(onTouch)
You wouldn't want a LocalScript for this and neither of those use GamePasses. I would do something like this-
local GamePassId = 0 -- Put your GamePassId here
local Lethal = true -- Set to false if you don't want it to kill
local OpenTime = 3 -- Time the door stays open in seconds
local GPS = Game:GetService("GamePassService")
local Players = Game:GetService("Players")
local Door = script.Parent
Door.Touched:connect(function(part)
local plr = Players:GetPlayerFromCharacter(part.Parent)
if plr then
if GPS:PlayerHasPass(plr, GamePassId) then
Door.CanCollide = false
Door.Transparency = .5
wait(OpenTime)
Door.Transparency = 0
Door.CanCollide = true
else
if Lethal then
plr.Character:BreakJoints()
end
end
end
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
