I'm not sure if I'm going about this the right way, but what I'm trying to do is create a BodyVelocity to the player's HumanoidRootPart then clone a script inside of that to destroy it. The code is here:
local replicatedStorage = game:GetService("ReplicatedStorage") local debounce = false function onTouched(other) if debounce == false then local rootPart = other.Parent:FindFirstChild("HumanoidRootPart") if rootPart ~= nil then local vol = Instance.new("BodyVelocity") vol.Velocity = Vector3.new(200, 0, 0) local clone = replicatedStorage:FindFirstChild("scripts").destroy:Clone() clone.Parent = vol vol.Parent = rootPart wait(1) debounce = false end end end script.Parent.Touched:Connect(onTouched)
It errors when trying to clone from replicatedStorage with: attempt to index function with 'Clone'
I am also completely open to other ways of launching a player.
At the local clone, you did .destroy:Clone() and destroy is a feature you can do so the script thinks you're trying to destroy something named clone
Like this
local replicatedStorage = game:GetService("ReplicatedStorage") local debounce = false function onTouched(other) if debounce == false then local rootPart = other.Parent:FindFirstChild("HumanoidRootPart") if rootPart ~= nil then local vol = Instance.new("BodyVelocity") vol.Velocity = Vector3.new(200, 0, 0) local clone = replicatedStorage:FindFirstChild("scripts").["destroy"]:Clone() clone.Parent = vol vol.Parent = rootPart wait(1) debounce = false end end end script.Parent.Touched:Connect(onTouched)
Why do you need a seperate script to destroy it? You can use game:GetService("Debris"):AddItem(Item,Duration) It will destroy Item in Duration seconds. Matt's answer is correct, but they didn't fix the problem. Changing destroy to DestroyScript fixed the problem, but adding ["destroy"] still comes out as scripts.destroy. It just allows you to add more to the string like ["destroy".. "red"] would be scripts.destroyred
--Possible easier way, unless you absolutely have to have a seperate script to destroy it --replace local clone --- vol.Parent with --game:GetService("Debris"):AddItem(vol,10) -- This will destroy vol after 10 seconds local replicatedStorage = game.ReplicatedStorage local debounce = false function onTouched(other) if debounce == false then local rootPart = other.Parent:FindFirstChild("HumanoidRootPart") if rootPart ~= nil then local vol = Instance.new("BodyVelocity") vol.Velocity = Vector3.new(200, 0, 0) local clone = replicatedStorage:FindFirstChild("scripts").DestroyScript:Clone() -- Naming your script destroy was your issue, renaming it fixed the problem. clone.Parent = vol vol.Parent = rootPart wait(1) debounce = false end end end script.Parent.Touched:Connect(onTouched)