How can I make a cannon that shoots players when they touch?

CFrame.new(part.Position)
or
CFrame.new(Vector3.new(0,0,0))
like this

also that cframe value should be the cframe of the cannon NOT where the player ends up

1 Like

This is happening to me when I put the script:
robloxapp-20210611-2249142.wmv (2.5 MB)

first add a debounce and also this script wont work if the cannon was just a part it should be a real cannon where the hole is the same size as the character

1 Like

Thanks, for your help, but @testattempt and your script worked, but I couldn’t stand after I was launched for your script. Thanks. :smiley:

you just have to have a local script in the player that checks if the player falls on floor and make him to stand

1 Like

Oh, ok, I will try to do that now.

I made a script like this, I don’t think it will work. Also, I put the localscript in StarterPlayer > StarterPlayerScripts. Thanks.

local player = game.Players

player.humanoid.sit = false then
	player.humanoid.sit = true
end

I haven’t seen a script this messed up since '89. How did you manage to spell function and misdirect players?
OP is probably looking for this:

local part = script.Parent
local players = game:GetService("Players")

part.Touched:Connect(function(hit()
	local plr = players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		local bodyforce = Instance.new("BodyForce", plr.Character.HumanoidRootPart)
		bodyforce.Force = Vector3.new(2500,4500,-2500)
		plr.Character.HumanoidRootPart.Velocity = Vector3.new(200)
	end
end)

Note: I only fixed errors in their script to do replied users intent, I do not have the time to actually review it to make sure it will actually do what OP wanted.

1 Like

hey .Velocity is deprecated …

Is there any way to check if player is sitting or not? Thanks.

Deprecated, won’t directly error so not my problem.

you could do

if plr.Humanoid.Sit then
-- ...
end
1 Like

I found the solution, @Creeperman16487 had a similar character motion that I wanted, and I added @testattempt’s hit.Parent.Humanoid.Sit = true to @Creeperman16487’s script. Thank you for your help.
Also, @barfpillow99, @Zalstice, and @Kaid3n22, Thank you too.

would be kinda cool if you shared the whole edited code so that it helps future people ??

2 Likes

Here is the script for other people that need help with something similar:

local part = script.Parent
local players = game.Players

part.Touched:Connect(function(hit)
	local plr = players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		hit.Parent.Humanoid.Sit = true
		plr.Character.Humanoid.PlatformStand = true
		local bodyforce = Instance.new("BodyForce", plr.Character.HumanoidRootPart)
		bodyforce.Force = Vector3.new(2500,4500,-2500)
		plr.Character.HumanoidRootPart.Velocity = Vector3.new(200)
	end
end)

Credit to @testattempt, and @Creeperman16487, Thank you. :smiley:

2 Likes