Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

2 comments

0

Somehow you are trying to use LocalScript elements in a ServerScript, like game.Players.LocalPlayer

0

This here is the localscript, sorry to confuse you.

1 answer

✓ Accepted answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.