so like its rewarding all clients and i dont want that how do i fix this???
local rep = game.ReplicatedStorage local remote = rep:WaitForChild("ChangeValue") debounce = true while true do wait(1) local plr = game:GetService("Players").LocalPlayer local Gui = plr.PlayerGui.Quest:WaitForChild("DOIT") local Gui1 = plr.PlayerGui.Quest:WaitForChild("Framo") local Humanoid = game.Workspace.ThiefBoss:FindFirstChild("Enemy") Humanoid.Touched:Connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if Humanoid ~= nil and debounce == true then debounce = false game.Players:GetPlayerFromCharacter(hit.Parent) Humanoid.Died:Connect(function() if hit.Parent then Gui:TweenSize(UDim2.new(0,227,0,152), Enum.EasingDirection.In, Enum.EasingStyle.Elastic,1,true,nil) wait(1) Gui.Visible = false if Gui.Visible == false then Gui1.TextLabel.Text = "Thank you for defeating the Thief Boss" remote:FireServer("Quest") wait() debounce = true end end end) end end) end
You will have to detect who touched the player last so that you know who killed him
This should be in a serverscript and will be something along the lines of
local rep = game.ReplicatedStorage local remote = rep:WaitForChild("ChangeValue") local plr = game:GetService("Players").LocalPlayer local Gui = plr.PlayerGui.Quest:WaitForChild("DOIT") local Gui1 = plr.PlayerGui.Quest:WaitForChild("Framo") local Humanoid = game.Workspace.ThiefBoss:FindFirstChild("Enemy") local lastTouch Humanoid.Touched:Connect(function(hit) local p = game.Players:GetPlayerFromCharacter(hit.Parent) if p then lastTouch = p end end) Humanoid.Died:Connect(function() local playerWhoKilled = lastTouch --Do stuff here end)