I’m trying to experiment and although this is one of the worse ways of making a gun, I’m gonna try it and see how it goes, experience matters, doesn’t it?
The issue is that Activated event does not fire/run/get triggered after I click with the tool that I have equipped (pistol).
I didn’t try anything because I have no idea as to what the issue is.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local script:
print("something")
local pistol = script.Parent
local bullet = game:GetService("ReplicatedStorage"):WaitForChild("Bullet")
local Handle = game:GetService("ReplicatedStorage"):WaitForChild("Handle")
local bulletpart = pistol:WaitForChild("BulletPart")
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local LowerTorso = character:WaitForChild("LowerTorso")
local TweenService = game:GetService("TweenService")
local mouse = player:GetMouse()
Handle.Parent = game.Workspace
local weld = Instance.new("WeldConstraint")
weld.Part0 = LowerTorso
weld.Part1 = Handle
Handle.Position = LowerTorso.Position + Vector3.new(1.25,-0.275,0)
weld.Parent = LowerTorso
pistol.Equipped:Connect(function()
Handle.Parent = game:GetService("ReplicatedStorage")
local weld = Instance.new("WeldConstraint")
weld.Part0 = LowerTorso
weld.Part1 = Handle
Handle.Position = LowerTorso.Position + Vector3.new(1.25,-0.275,0)
weld.Parent = LowerTorso
end)
pistol.Unequipped:Connect(function()
Handle.Parent = game.Workspace
local weld = Instance.new("WeldConstraint")
weld.Part0 = LowerTorso
weld.Part1 = Handle
Handle.Position = LowerTorso.Position + Vector3.new(1.25,-0.275,0)
weld.Parent = LowerTorso
end)
pistol.Activated:Connect(function()
print("cool")
game:GetService("ReplicatedStorage").RemoteFunction:FireServer(bullet, bulletpart, mouse)
end)
print("something else")
it prints everything here, except for “cool”
server script that the local script is connected to:
print("lol")
local TweenService = game:GetService("TweenService")
game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction").OnServerInvoke = function(player, bullet, bulletpart, mouse)
print("Started")
local newbullet = bullet:Clone()
newbullet.Parent = workspace
newbullet.Position = bulletpart.Position
local distance = (newbullet.Position - mouse.Target.Position).Magnitude
local tween = TweenInfo.new(
distance,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
false,
0
)
local finish =
{
Position = mouse.Target
}
local tweenPlay = TweenService:Create(bullet, tween, finish)
tweenPlay:Play()
print("Finshed")
end
server script placing the tool into player’s StarterGear:
local pistol = game:GetService("ReplicatedStorage"):WaitForChild("Pistol")
game.Players.PlayerAdded:Connect(function(player)
pistol.Parent = player.StarterGear
end)
please let me know if I made a mistake somewhere, as I don’t really see anything wrong.
Thanks for reading!