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

Simple blur and teleport activates when it isn't supposed to + debounce not working?

Asked by 6 years ago

Okay, so I don't know why I'm so bad at camera effects, but here we go again with a camera effect bug.

Basically, it should be so when you step on the teleport, it starts to blur you screen until the blur size is 50, then it will teleport you, then unblur you screen, and finally destroy the blur effect altogether.

But the function fires when you spawn in.

I found this didn't work in a regular script, because of teleporting, so i put it in a LocalScript. I randomly put the Localscript in Statergui.

i know it's easier not to put it in a localscript, but i was just so confused, that's what i thought of.

Here is the code:

local debounce = false

function teleman(plr)
    if not debounce then
        debounce = true

    local blur = Instance.new("BlurEffect")
    blur.Parent = workspace.CurrentCamera
    for i = 1, 50, 1 do
        blur.Size = i
        wait(0.1)
    end
    game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-1551.94, 4331.919, 1020.52))
    wait(1)
    for i = 50, 1, -1 do
        blur.Size = i
        wait(0.1)
    end
    blur:Destroy()
    end
    wait(5)
    debounce = false

end

workspace.Telepad.Touched:connect(teleman)

It uses for i = 1, 50, 1 to make the blur size go up by one each "0.1" seconds, and the second for loop makes it go down each "0.1" seconds. The teleport is a simple teleport I got off the wiki.

I think it's the debounce script making this fire when a player spawns in, but I could be wrong. Also, the debounce isn't even working, so that backs up my theory even more.

Anyway, if anyone knows the answer, please tell me. Thanks!

0
Somehow you are trying to use LocalScript elements in a ServerScript, like game.Players.LocalPlayer thesit123 509 — 6y
0
This here is the localscript, sorry to confuse you. 0HappyManDudeguy0 15 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

The touched event will fire when any part touches your telepad, not just when a player touches it, so in your case it's likely the ground underneath the pad that is firing the touched event when the game begins. To make it so that it only fires when a player touches the pad, you need to add a check in your touched function. So adding:

function teleman(plr)
    local character = plr.Parent
    local humanoid = character:FindFirstChild('Humanoid')
    if humanoid then
        if not debounce then
            debounce = true

            -- The rest of your code here
        end
        wait(5)
        debounce = false
    end
end

Should fix your problems. Your code of course only teleports the local player no matter what player steps on the teleport pad. Better would be to put this in a script instead of a local script, put it in ServerScriptService, and change your teleport line to: character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(-1551.94, 4331.919, 1020.52)) Hope that helps.

Ad

Answer this question