With this script i'm just trying to make a projectile spawn and move. It worked before I tried to add FE but just doesn't work at all when I attempted to implement it. I'm still pretty iffy on FE so I have no idea what to do next.
Local Script
local function fds() script.Parent.Equipped:connect(function(mouse) mouse.Button1Down:connect(function() local bullet = game:GetService("ReplicatedStorage").Bullet:Clone() bullet.CFrame = script.Parent.muzzle.CFrame bullet.Parent = workspace bullet.Velocity = bullet.CFrame.lookVector * 600 end) end) end game:GetService("ReplicatedStorage").GunShoot.OnClientEvent:Connect(fds)
Script
game:GetService("ReplicatedStorage").GunShoot:FireClient()
I am just getting back into script after a couple months so I forgot a bunch of stuff.
You shouldn't connect a function to Equipped each time you receive a FireClient
.
Same for Equipped, you shouldn't connect a new function to Button1Down every time you equip the tool.
Instead, you should handle the decision of the gun firing on the server.
-- Client below local isEquipped = false; local gunTool = game.Players.LocalPlayer.Backpack:WaitForChild'gunTool' local uis = game:GetService'UserInputService' gunTool.Equipped:Connect(function() isEquipped = not isEquipped -- turns false if true, turns true if false end) uis.InputBegan:Connect(function(input, typing) if not typing then if input == Enum.UserInputType.MouseButton1 then game.ReplicatedStorage.GunShoot:FireServer() -- server will handle end end end) -- Server below game.ReplicatedStorage.GunShoot.OnServerEvent:connect(function(p) local bullet = game:GetService("ReplicatedStorage").Bullet:Clone() bullet.CFrame = p.Character.gunTool.muzzle.CFrame bullet.Parent = workspace bullet.Velocity = bullet.CFrame.lookVector * 600 end)