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

Help With A Touched Script?

Asked by
Scootakip 299 Moderation Voter
8 years ago
s = script.Parent.Parent.Head
w = script.Parent.Parent
local r = script.Parent
local players = game:GetService("Players")

r.Touched:connect(function(part)
    local player = part and part.Parent and players:GetPlayerFromCharacter(part.Parent)
    if player then
    local humanoid = part.Parent:FindFirstChild("Humanoid").Parent
    if humanoid.Name == "Scootakip" then
        w.Name = "Lolyeh"
        s.BrickColor = BrickColor.new("Really blue")
        wait(5)
        w.Name = "Find Out If You're Scootakip"
        s.BrickColor = BrickColor.new("White")
    end
    if humanoid.Name ~= "Scootakip" then
        w.Name = "NO"
        s.BrickColor = BrickColor.new("Really red")
        wait(5)
        w.Name = "Find Out If You're Scootakip"
        s.BrickColor = BrickColor.new("White")
    end

    end
end)

This script works fine the way it is, but I need help changing it. Right now if you step on it, something activates and then goes back to normal 3 seconds after, but what I want is that it stays activated as long as the player is on the brick, and deactivates as soon as they step off. Can someone either tell me how to do that or give me a link to a page that will tell me how to do it?

1
The TouchEnded event works, but it tends to do weird things if multiple people are on the brick, so I'd probably end up using magnitude. Perci1 4988 — 8y

Answer this question