Death gui scripting

so i wanted to make on death gui and trigger events with this script but it isn’t trigger

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character) --every time he spawns
		print(player.Name.." has spawned in / respawned")
		script.Parent.DeadEnd:Fire()
		player.CameraMaxZoomDistance = 0.5
		character:WaitForChild("Humanoid").Died:Connect(function() --every time he dies and NOT respawns
			print(player.Name.." has died!")
			player.CameraMaxZoomDistance = 400
			script.Parent.DeadStart:Fire()
		end)
	end)
end)

its local script

2 Likes

Could you provide the code that handles the “DeadEnd” event?

1 Like
function effects()
	local deadblur = game.Lighting:FindFirstChild("deadblur")
	local deadwb = game.Lighting:FindFirstChild("deadwb")
	deadwb:Destroy()
	deadblur:Destroy()
end

script.Parent.DeadStart.Event:Connect(effects)

function gui()
	script.Parent.Parent.Parent.Loading.Enabled = true
	script.Parent.Parent.Parent.MainGui.Enabled = true
	script.Parent.Parent.Parent.portrait.Enabled = true
end

script.Parent.DeadStart.Event:Connect(gui)

function timee()
	script.Parent.time.Text = 0
end

script.Parent.DeadStart.Event:Connect(timee)
script.Parent.Parent.Parent.DeathGui.Enabled = false
1 Like

its local script

oh my god this is supposed to be server script :man_facepalming:

I assume this is a script and the other one is a local script right? Because if not, the first one must be a script in order to work (also then change it to a remote event)

Okay, could you tell what exactly doesn’t work and also send in the handle script of the “DeadStart” event?

this doesnt make any sense

BindableEvent will not replicate to client

BindableEvent works like this

server fires it → server recieves info from bindable

client fires it → client recieves info from bindable

I just saw it, I changed my message

Well I don’t really see a problem of it being a localscript, he’s firing events to make the effects serversided etc.

oh my godddddddddddddddddd

when did you start scripting in luau?

That’s absolutely off topic, you can correct me and all that stuff but your question doesn’t help the original poster.

please hear me out

this doesnt look like LocalScript

this code looks like it would be used in Script

local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character) --every time he spawns
		print(player.Name.." has spawned in / respawned")
		script.Parent.DeadEnd:Fire()
		player.CameraMaxZoomDistance = 0.5
		character:WaitForChild("Humanoid").Died:Connect(function() --every time he dies and NOT respawns
			print(player.Name.." has died!")
			player.CameraMaxZoomDistance = 400
			script.Parent.DeadStart:Fire()
		end)
	end)
end)
1 Like

you need to change your thing OP

local players = game:GetService("Players")
local deadEnd=Instance.new("RemoteEvent",game:GetService("ReplicatedStorage"))
deadEnd.Name="DeadEnd"
local deadStart=Instance.new("RemoteEvent",game:GetService("ReplicatedStorage"))
deadStart.Name="DeadStart"
players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character) --every time he spawns
		print(player.Name.." has spawned in / respawned")
		deadEnd:FireClient(player)
		--player.CameraMaxZoomDistance = 0.5 move this to localscript
		character:WaitForChild("Humanoid").Died:Connect(function() --every time he dies and NOT respawns
			print(player.Name.." has died!")
			--player.CameraMaxZoomDistance = 400 move this to localscript too
			deadStart:FireClient(player)
		end)
	end)
end)
1 Like

then

WaitForChild for those remote events in LocalScript (i recommend parenting your localscript to ReplicatedFirst)

and then .OnClientEvent so you can listen every each time player dies from server

I noticed something on both scripts, it seems like they are both in the same Hierachy because both use

script.Parent.DeadEnd/DeadStart

Bindables should only be really used when they are seperated from each other and as @Bakonowychlopak123 said

this code looks like it would be used in Script

im pretty sure he uses it incorrectly

function gui()
	script.Parent.Parent.Parent.Loading.Enabled = true
	script.Parent.Parent.Parent.MainGui.Enabled = true
	script.Parent.Parent.Parent.portrait.Enabled = true
end

like what the heck is this

and he put it into ServerScriptService god damn it the one handling effects should be LocalScript :skull:
also Parent.Parent.Parent spam

from localscript he should get PlayerGui like this

local lplr=game:GetService("Players").LocalPlayer
local plrgui=lplr:WaitForChild("PlayerGui") and lplr:FindFirstChildOfClass("PlayerGui")
plrgui.MainGui.Enabled = true
plrgui.portrait.Enabled = true
plrgui.Loading.Enabled = true
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.