I have been working on a prototype for a Sword-Fight duel game, and almost finished Kill Effects, but one problem is, it doesn’t work at all, and I get zero errors.
I saw a devforum post about this, but it still didn’t fix my problem.
Heres my code:
local DataStore2 = require(game.ReplicatedStorage.DataStore2)
function KILLDEATH(plr, killer)
local data = DataStore2("KillFX", killer)
local testData = "LOWTIERGOD"
if testData == "LOWTIERGOD" then
local LTG_1 = script.Audio.LTG:Clone()
local LTG_2 = script.BillboardGUI.LTG:Clone()
LTG_1.Parent = plr.Character.Torso
LTG_2.Parent = plr.Character.Head
wait(LTG_1.TimeLength)
LTG_1:Destroy()
LTG_2:Destroy()
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
KILLDEATH(player, player.Character.Humanoid:GetLastDamage())
end)
end)
end)
KILLDEATH() handles the player and the killer, and makes the kill effects work.
It worked when I used testData but now when I get the Actual Data with DataStore 2 it just doesn’t work at all.
local DataStore2 = require(game.ReplicatedStorage.DataStore2)
function KILLDEATH(plr, killer)
local NewBase = DataStore2("KillFX",plr) -- read values instead cuz im dumb
local data = NewBase:Get()
print(data)
if data == "LOWTIERGOD" then
local LTG_1 = script.Audio.LTG:Clone()
local LTG_2 = script.BillboardGUI.LTG:Clone()
LTG_1.Parent = plr.Character.UpperTorso
LTG_1:Play()
LTG_2.Parent = plr.Character.Head
wait(20)
LTG_1:Stop()
LTG_1:Destroy()
LTG_2:Destroy()
plr:LoadCharacter()
elseif data == "Green Sparkles" then
local SP = script.FX.Green:Clone()
local AU = script.Audio.Funny:Clone()
SP.Parent = plr.Character.UpperTorso
AU.Parent = plr.Character.UpperTorso
AU:Play()
wait(5)
AU:Stop()
SP:Destroy()
AU:Destroy()
plr:LoadCharacter()
elseif data == "Blue Sparkles" then
local SP = script.FX.Blue:Clone()
local AU = script.Audio.Funny:Clone()
SP.Parent = plr.Character.UpperTorso
AU.Parent = plr.Character.UpperTorso
AU:Play()
wait(5)
AU:Stop()
SP:Destroy()
AU:Destroy()
plr:LoadCharacter()
elseif data == "Red Sparkles" then
local SP = script.FX.Red:Clone()
local AU = script.Audio.Funny:Clone()
SP.Parent = plr.Character.UpperTorso
AU.Parent = plr.Character.UpperTorso
AU:Play()
wait(5)
AU:Stop()
SP:Destroy()
AU:Destroy()
plr:LoadCharacter()
elseif data == "Toxic" then
local TOX_1 = script.Audio.TOXIC:Clone()
local TOX_2 = script.BillboardGUI.TOXIC:Clone()
TOX_1.Parent = plr.Character.UpperTorso
TOX_1:Play()
TOX_2.Parent = plr.Character.Head
wait(5)
TOX_1:Stop()
TOX_1:Destroy()
TOX_2:Destroy()
plr:LoadCharacter()
elseif data == "Sideeye" then
local SID_1 = script.Audio.SIDEEYE:Clone()
local SID_2 = script.BillboardGUI.SIDEEYE:Clone()
SID_1.Parent = plr.Character.UpperTorso
SID_1:Play()
SID_2.Parent = plr.Character.Head
wait(7)
SID_1:Stop()
SID_1:Destroy()
SID_2:Destroy()
plr:LoadCharacter()
elseif data == "2 ez" then
local EZ_1 = script.Audio["2EZ"]:Clone()
local EZ_2 = script.BillboardGUI["2EZ"]:Clone()
EZ_1.Parent = plr.Character.UpperTorso
EZ_1:Play()
EZ_2.Parent = plr.Character.Head
wait(5)
EZ_1:Stop()
EZ_1:Destroy()
EZ_2:Destroy()
plr:LoadCharacter()
elseif data == "Horror" then
local HOR_1 = script.Audio.HORROR:Clone()
local HOR_2 = script.BillboardGUI.HORROR:Clone()
HOR_1.Parent = plr.Character.UpperTorso
HOR_1:Play()
HOR_2.Parent = plr.Character.Head
wait(5)
HOR_1:Stop()
HOR_1:Destroy()
HOR_2:Destroy()
plr:LoadCharacter()
elseif data == "Flash" then
local GUI = script.GUI.flashdeath:Clone()
GUI.Parent = plr.PlayerGui
wait(3)
GUI:Destroy()
plr:LoadCharacter()
elseif data == "Sword" then
local GUI = script.GUI.sworddeath:Clone()
GUI.Parent = plr.PlayerGui
wait(3)
GUI:Destroy()
plr:LoadCharacter()
elseif data == "Gate" then
local GUI = script.GUI.gate:Clone()
GUI.Parent = plr.PlayerGui
wait(3)
GUI:Destroy()
plr:LoadCharacter()
elseif data == "Waste" then
local HOR_1 = script.Audio.HORROR:Clone()
HOR_1.Parent = plr.Character.UpperTorso
HOR_1:Play()
wait(10)
HOR_1:Stop()
HOR_1:Destroy()
plr:LoadCharacter()
elseif data == "Buggati" then
local GUI = script.GUI.gate:Clone()
local AUD = script.Audio.BUGGATI:Clone()
AUD.Parent = plr.Character.UpperTorso
GUI.Parent = plr.PlayerGui
AUD:Play()
wait(5)
AUD:Stop()
GUI:Destroy()
plr:LoadCharacter()
elseif data == "banan" then
local GUI = script.GUI.BANANA:Clone()
local AUD = script.Audio.BANANA:Clone()
AUD.Parent = plr.Character.UpperTorso
GUI.Parent = plr.PlayerGui
AUD:Play()
wait(3)
AUD:Stop()
GUI:Destroy()
plr:LoadCharacter()
elseif data == "Normal" then
local hiDebug = "so it wont cancel the FUNCTION RAHHHH"
wait(5)
plr:LoadCharacter()
end
end
game.Players.PlayerAdded:Connect(function(player)
game.Players.CharacterAutoLoads = false
player:LoadCharacter()
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
local tag = player.Character.Humanoid:FindFirstChild("creator")
if tag ~= nil then
local killer = tag.Value
KILLDEATH(player, killer)
print('real')
end
end)
end)
end)