So I have a knife, and a (server) script that handles whatever knife is thrown (this script is placed inside the knife, defined as base) and every time It hits a wall that IS NOT either the player throwing the knife (defined as tag) or a wall.
Problem: It does not actually delete. Question: How do I fix this so it does delete itself?
Common Errors shown: GetPlayerFromCharacter is not a valid member of Model "__"
base=script.Parent
tag=base.OwnerTag
player=base.OwnerNString
event = game:GetService("ReplicatedStorage")["KnifeDataTransferEvent"]
enabled=true
base.Touched:Connect(function(part)
if part:IsDescendantOf(tag.Value.Character)==false then
if enabled==true then
if part.Parent:FindFirstChildWhichIsA("Humanoid") or part.Parent:GetPlayerFromCharacter() then
local enemy=part.Parent
if (tag.Team~=enemy:GetPlayerFromCharacter().Team) or (tag.Team==nil and enemy:GetPlayerFromCharacter().Team==nil) (tag.Team==nil and enemy.Parent:GetPlayerFromCharacter().Team==nil) then
event:FireClient(tag.value,"Damage",base,enemy,nil)
else
base:Destroy()
end
base:Destroy()
end
end
end
end)

1 comment
oh my god thank you so much this saved me so much time trying to fix it myself