I have a local script that detects when a tool is activated. When the tool is activated, it fires a remote event that fires a bullet from the gun. It works fine when you play test, but when I test it on a server, it doesn't work. What am I doing wrong?
Edit: I have the print scripts to test what isn't working. The only thing that it printed was "oy mate im activated."
(Filtering is enabled)
Local Script:
local repStorage = game:GetService("ReplicatedStorage") local remote = repStorage:WaitForChild("Remote")
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Remote")
_G.Gun = script.Parent
_G.Gun.Activated:connect(function()
remote:FireServer()
print("oy mate im activated")
end)
Script:
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage:WaitForChild("Remote")
remote.OnServerEvent:connect(function()
local Player = game.Players.LocalPlayer
local Ammo = 5
local mouse = Player:GetMouse()
if Ammo > 0 then
print("Hey I shot a thing!!")
local Bullet = Instance.new("Part", workspace)
game.Debris:AddItem(Bullet, 2)
Bullet.Shape = "Ball"
Bullet.Size = Vector3.new(3, 3, 3)
Bullet.TopSurface = "Smooth"
Bullet.BottomSurface = "Smooth"
Bullet.BrickColor = BrickColor.new("Dark stone grey")
Bullet.CanCollide = false
Bullet.CFrame = _G.Gun.Handle.CFrame
Bullet.CFrame = CFrame.new(Bullet.Position,mouse.Hit.p)
local v = Instance.new("BodyVelocity", Bullet)
v.velocity = Bullet.CFrame.lookVector *90
v.maxForce = Vector3.new(math.huge, math.huge, math.huge)
end
end)
Thanks!
