How do I make GUI clientside?

I’m trying to make an effect so that if you touch something an imagelabel and a blur will pop up, I have gotten all of that working but despite using a localscript, when someone touched the part everyone in the server regardless of where they are or having touched the part sees the effects
I am using this code in my localscript:

local DamagePart = workspace.KingOfficeVentSys:WaitForChild("DamagePart")
local TweenService = game:GetService("TweenService")
local VignetteTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local BlurTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local TextTweenInfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local DeBlurrerInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local Vignette1 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel1
local Vignette2 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel2
local Vignette3 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel3
local Text = game.Players.LocalPlayer.PlayerGui.VentEffect.TextLabel
local Blurrer = game.Lighting.Blur

local VignetteTween1 = TweenService:Create(Vignette1, VignetteTweenInfo, {ImageTransparency = 0})
local VignetteTween2 = TweenService:Create(Vignette2, VignetteTweenInfo, {ImageTransparency = 0})
local VignetteTween3 = TweenService:Create(Vignette3, VignetteTweenInfo, {ImageTransparency = 0})
local BlurTween = TweenService:Create(Blurrer, BlurTweenInfo, {Size = 56})
local DeBlurrer = TweenService:Create(Blurrer, DeBlurrerInfo, {Size = 0})
local TextTween = TweenService:Create(Text, TextTweenInfo, {TextTransparency = 0})

game.Workspace.KingOfficeVentSys.DamagePart.Touched:Connect(function(FXEnable)
	if FXEnable and FXEnable.Parent and FXEnable.Parent:FindFirstChild("Humanoid") then
		BlurTween:Play()
		VignetteTween1:Play()
		VignetteTween2:Play()
		game.Workspace.GlobalSoundStorage.Misc.Heartbeat:Play()
		wait(5)
		VignetteTween3:Play()
		game.Workspace.GlobalSoundStorage.Misc.EarRinging:Play()
		wait(8)
		TextTween:Play()
		wait(2)
		game.Workspace.GlobalSoundStorage.Misc.Heartbeat.Playing = false
		DeBlurrer:Play()
	end
end)

Thanks for the help.

Add another condition here that checks if FXEnable.Parent is equal to the local player’s character

how do i do that would it be like

if FXEnable and FXEnable.Parent and FXEnable.Parent:FindFirstChild("Humanoid") and FXEnable.Parent == LocalPlayer
then

if FXEnable and FXEnable.Parent and FXEnable.Parent:FindFirstChild(“Humanoid”) and game.Players:GetPlayerFromCharacter(FXEnable.Parent) == game.Players.LocalPlayer then

Should work

game.Players.LocalPlayer.Character
You can set that as a variable in the localscript, assuming that your localscript is in a ScreenGui whose .ResetOnSpawn property is true

my localscript is inside the startercharacterscripts directory and it does reset on spawn

That should work too cuz it gets replicated every time the character is made

Edit:

This will work too

i tried that and it gave me this error:

  21:59:39.572  Players.thekingorespawn.PlayerScripts.VentEffectScript:21: Expected identifier when parsing expression, got Unicode character U+201c (did you mean '"'?)  -  Studio - VentEffectScript:21

i replaced the quotes with apostrophes and than the error went away, however the effects are now completely gone when i touch the part

Edit: How should I incorporate this line of code into the rest of the script?

Could you show me the full script?

local DamagePart = workspace.KingOfficeVentSys:WaitForChild("DamagePart")
local TweenService = game:GetService("TweenService")
local VignetteTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Sine,Enum.EasingDirection.In)
local BlurTweenInfo = TweenInfo.new(10,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local TextTweenInfo = TweenInfo.new(1.5,Enum.EasingStyle.Sine,Enum.EasingDirection.Out)
local DeBlurrerInfo = TweenInfo.new(2,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local Vignette1 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel1
local Vignette2 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel2
local Vignette3 = game.Players.LocalPlayer.PlayerGui.VentEffect.ImageLabel3
local Text = game.Players.LocalPlayer.PlayerGui.VentEffect.TextLabel
local Blurrer = game.Lighting.Blur

local VignetteTween1 = TweenService:Create(Vignette1, VignetteTweenInfo, {ImageTransparency = 0})
local VignetteTween2 = TweenService:Create(Vignette2, VignetteTweenInfo, {ImageTransparency = 0})
local VignetteTween3 = TweenService:Create(Vignette3, VignetteTweenInfo, {ImageTransparency = 0})
local BlurTween = TweenService:Create(Blurrer, BlurTweenInfo, {Size = 56})
local DeBlurrer = TweenService:Create(Blurrer, DeBlurrerInfo, {Size = 0})
local TextTween = TweenService:Create(Text, TextTweenInfo, {TextTransparency = 0})

game.Workspace.KingOfficeVentSys.DamagePart.Touched:Connect(function(FXEnable)
	if FXEnable and FXEnable.Parent and FXEnable.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(FXEnable.Parent) == LocalPlayer then
		BlurTween:Play()
		VignetteTween1:Play()
		VignetteTween2:Play()
		game.Workspace.GlobalSoundStorage.Misc.Heartbeat:Play()
		wait(5)
		VignetteTween3:Play()
		game.Workspace.GlobalSoundStorage.Misc.EarRinging:Play()
		wait(8)
		TextTween:Play()
		wait(2)
		game.Workspace.GlobalSoundStorage.Misc.Heartbeat.Playing = false
		DeBlurrer:Play()
	end
end)

I replaced the apostrophes with quotes again and it didnt give me an output error but it does still break the effects

LocalPlayer is not a variable in the script. Either make it a variable or replace it with game.Players.LocalPlayer

if FXEnable and FXEnable.Parent and FXEnable.Parent:FindFirstChild(“Humanoid”) and game.Players:GetPlayerFromCharacter(FXEnable.Parent) == LocalPlayer then

Replace Local Player with

game.Players.LocalPlayer

i did this and it has brought the effects back, i need to check with a friend to see if the effect is clientside though

It won’t be. if you want to test you can go to the Test section, make it two players and press Start.

image

alright, a friend joined as soon as you said that so i didnt need to try it but this all worked, the effects are clientside and the bugs are fixed.

1 Like

You have a variable called “DamagePart” that’s be defined but never used. Bad practise to do such a thing, later in the code you need it but you’re referencing it straight from the workspace. Also, this is a local script using Touched? I don’t recommend using Touched on the client for many reasons, despite the fact that the Touched Script Signal relies on the client position rather than the server position for “less delay”. I’d recommend doing checks to see if their position is valid, on the server. And handle Touched events on the server. To make this work for only one player, you’d have to use Local Player. so game.Players.LocalPlayer