I have rocket script and what i want it to do is, When the rocket hits a part, it gives you point. I already have the Point Leader Board and it works fine, but i have been experimenting in putting a script in the rocket script that will give you a point when it hits something but i have failed every time and i don't know where to put it in the rocket script and i don't know what to put in the rocket script to give you a point when it hits a part, i need help. Please.

Here Is The Point Leader Board

game.Players.PlayerAdded:connect(function(player)
    local leaderstats = Instance.new("Model")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player
    local money = Instance.new("IntValue")
    money.Name = "Money"
    money.Value = 0
    money.Parent = leaderstats
end)

Here Is The Rocket Script


r = game:service("RunService")

shaft = script.Parent
position = shaft.Position

script.Parent.Explosion.PlayOnRemove = true

function fly()
	direction = shaft.CFrame.lookVector 
	position = position + direction
	error = position - shaft.Position
	shaft.Velocity = 7*error
end

function blow()
	swoosh:stop()
	explosion = Instance.new("Explosion")
	explosion.Position = shaft.Position


	
	local creator = script.Parent:findFirstChild("creator")
	if creator ~= nil then
		explosion.Hit:connect(function(part, distance)  onPlayerBlownUp(part, distance, creator) end)
	end

	explosion.Parent = game.Workspace
	connection:disconnect()
	wait(.1)
	shaft:remove()
end

function onPlayerBlownUp(part, distance, creator)
	
	if part.Name == "Head" then
	
		local humanoid = part.Parent.Humanoid
		tagHumanoid(humanoid, creator)
	end
end

function tagHumanoid(humanoid, creator)
	
	
	if creator ~= nil then
		local new_tag = creator:clone()
		new_tag.Parent = humanoid
		
	end
end

function untagHumanoid(humanoid)
	if humanoid ~= nil then
		local tag = humanoid:findFirstChild("creator")
		if tag ~= nil then
		
			tag.Parent = nil
		end
	end
end

t, s = r.Stepped:wait()

swoosh = script.Parent.Swoosh
swoosh:play()

d = t + 10.0 - s
connection = shaft.Touched:connect(blow)

while t < d do
	fly()
	t = r.Stepped:wait()
end


script.Parent.Explosion.PlayOnRemove = false
swoosh:stop()
shaft:remove()

2 comments

0

Is this your own script?

0

The Leader Board script is mine but the rocket one is not. I'm trying to edit the rocket script so it will give me a point when it hits something.