[HELP ASAP] Code wont work as intended

local Projectile = script.Projectile
local ProxProm = script.Parent.ProximityPrompt
local VehicleSeat = script.Parent.Parent.VehicleSeat
local canshoot = true

local function FIRE()
	Projectile.Effects.Enabled = true
	local c = Projectile:Clone()
	c.Name = "Bomb"
	c.Parent = workspace
	c.Velocity = (c.CFrame.LookVector * 250)
	c.Effects:Destroy()
	c.Touched:Connect(function(hit)
		if not hit:IsDescendantOf(script.Parent.Parent) then
			local explosion = Instance.new("Explosion",workspace)
			explosion.Position = c.Position
			c:Destroy()
		end
	end)
	wait(0.5)
	Projectile.Effects.Enabled = false
	wait(4)
	ProxProm.Enabled = true
end

local db = false

local CanJoint = VehicleSeat.Cannon
local Cannon = script.Parent
local RE = game.ReplicatedStorage.PositionCannon

ProxProm.Triggered:Connect(function(plr)
	if VehicleSeat.Occupant ~= nil and VehicleSeat.F.Force == Vector3.new(0,0,0) and canshoot == true then
		RE:FireClient(game.Players:GetPlayerFromCharacter(VehicleSeat.Occupant.Parent))
		Projectile.BrickColor = BrickColor.new("Really red")
		RE.OnServerEvent:Connect(function(plr,pos)
			if VehicleSeat.Occupant.Parent.Name == plr.Name then
				Projectile.BrickColor = BrickColor.new("Really black")
				CanJoint.C1 = CFrame.lookAt(CanJoint.C1.Position,pos):Inverse()
				FIRE()
			end
		end)
	end
end)

VehicleSeat.F.Changed:Connect(function()
	if VehicleSeat.F.Force ~= Vector3.new(0,0,0) then
		ProxProm.Enabled = false
	else
		ProxProm.Enabled = true
	end
end)

my code does not position the cannon upwards or downwards aka on the Z axis it only does on Y axis

[Removed the quote from the reply]

But either ways, are there possibly any errors in the output?

no errors not at all and sorry

1 Like

First of all, you are the one requesting someone to take their time to help you out. It is unprofessional to call one “rude” for not responding to your topic. Your behavior also discourages others to help you.

Second, your post is lacking detail. All you gave us is a copy and paste of a script, and a single sentence. You need to add videos, detailed descriptions, etc., and other things that would be helpful to solve the issue you are having.

3 Likes

It’s alright. But as Anonymous (not pinging) said you do need to provide more information about the issue.

As for example here, we don’t know from where the RemoteEvent is being fired.

1 Like

we need to see proof that there’s no error in the script(s), otherwise you’re missing something on the script.

yes yes i am sending the video wait

1 Like


ok so clearly the remote event fires to the client which returns a variable “pos” which is the mouse.hit.p CanJoint is a join in my vehicle seat that holds the cannon and positions it

1 Like

Now it explains a whole lot more. So, seems like the cannon isn’t going up/down (aka Y Axis). Pretty interesting, but I don’t see any problems with the script. And also, I do see people struggling with the Y axis of their code, so I really don’t blame you. I’ll try to get a working code (+Explanation).

so its kinda not the y axis its the z axis in rotation but yea and thanks

Y is up and down & Z is left and right.
image

EDIT: I might not be able to stay in touch today, so might do it tomorrow. Sorry to keep you waiting.

oh ok then haha thanks