I have an ability in my game that puts a player into a “stasis”
The stasis can be broken by certain characters
The issue I have is that I’m using an ObjectValue, and the Value is the player but when I try to use :FireClient(target) it says it’s not a player…
Here’s my script
local event = game.ReplicatedStorage:WaitForChild("Events"):WaitForChild("StasisBreak")
script.Parent.Triggered:Connect(function(player)
local target = game.Players:FindFirstChild(script.Parent.Parent.StasisPlayer.Value)
if player.Character:FindFirstChild("Warlock") and player.Name ~= target then
local anim = player.Character.Humanoid:LoadAnimation(game:GetService("ServerStorage"):WaitForChild("Animations"):WaitForChild("BreakStasis"))
anim:Play()
wait(4.5)
event:FireClient(target) -- it errors here
end
end)
the error i get
I still get the same error if I remove the target variable and do :FireClient(game.Players:FindFirstChild(script.Parent.Parent.StasisPlayer.Value)) instead…
Could you add some prints before the if statement and right before you call FireClient displaying target and target’s type. Looking at your if statement you are comparing player.Nam` to target so both should be strings if it passes the if statement but FindFirstChild returns Instance? so we need a little more information.
You can’t use :FindFirstChild on an object, only on its name. So, you do game:GetService("Players"):FindFirstChild(script.Parent.Parent.StasisPlayer.Value.Name) FindFirstChild will return nil if it doesn’t find anything, which is what caused your error.
local event = game:GetService("ReplicatedStorage"):WaitForChild("Events"):WaitForChild("StasisBreak")
event.OnServerEvent:Connect(function(target, brk)
if brk == "StasisBreak" then
if game.Workspace:FindFirstChild(target.Name.."Stasis") then -- here
local stasis = game.Workspace:FindFirstChild(target.Name.."Stasis")
stasis:Destroy()
for _,anims in pairs(target.Character.Humanoid:GetPlayingAnimationTracks()) do
if anims.Name == "Stasis" then
anims:Stop()
end
end
target.Character.Humanoid.WalkSpeed = 16
end
end
end)
It also shows the same error if i do (target.."Stasis")
nevermind, when i tested it with just target.."Stasis" i forgot to change the first part of it so it was still searching for target.Name.."Stasis" but then the second part where it destroys it, it was looking for target.."Stasis", so it was causing an error there.