Hey all, I am trying to make a throwable knife that just goes in a straight line when clicked.
I have an error stating: “TweenInfo is not a valid member of Part “Workspace.Kunai_Object” - Server - Script:15”
Here is the script I am using:
local ts = game:GetService("TweenService")
script.Parent.OnServerEvent:Connect(function(plr)
wait(.3) --startup
local head = plr.Character.Head
local sound = script.Parent.Parent.KnifeSound:Clone()
sound.Parent = head
sound:Play()
game.Debris:AddItem(sound,1)
local kunai = game.ReplicatedStorage.Kunai_Object:Clone()
kunai.Parent = workspace
kunai.CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 5
ts:Create(kunai.TweenInfo.new(3), {CFrame = plr.Character.HumanoidRootPart.CFrame + plr.Character.HumanoidRootPart.CFrame.lookVector * 150}):Play()
game.Debris:AddItem(kunai,3) --dissapear time
local touched = false
kunai.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= plr.Character and touched == false then
touched = true
hit.Parent.Humanoid:TakeDamage(50) -- damage dealt
end
end)
end)
As I am just starting to learn with the help of youtube tutorials, if you have any other advice on code layout or better/more efficient ways to do things, please tell me.
Thanks for any help given