Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make my gun FE Compatible?



local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local handle = tool.Handle



function onClick()
	local gunharm = Instance.new("Part", workspace)
	gunharm.Anchored = true
	gunharm.BrickColor = BrickColor.new("CGA brown")
	gunharm.Material = Enum.Material.Neon
	gunharm.Orientation = handle.Orientation
	gunharm.Name = "gunharm"
	gunharm.Size = Vector3.new(1.16, 0.41, 1.13)
	gunharm.Position = game.Players.LocalPlayer:GetMouse().Hit.p
	handle.Sound:Play()
	gunharm.Touched:connect(function(hit)
		hit.Parent:FindFirstChild("Humanoid").Health = hit.Parent:FindFirstChild("Humanoid").Health - 30
	end)
	wait(0.0006)
	gunharm:Destroy()
end

game.ReplicatedStorage.compat1:FireServer(player, onClick)
script.Parent.Activated:Connect(onClick)


Please help me.

1 answer

✓ Accepted answer
--Server Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = Instance.new("RemoteEvent")
remote.Parent = replicated
remote.Name = "damageRemote"

function damagePlayer(plr, target, dmg)
	target.Character.Humanoid:TakeDamage(dmg)
end
--Local script
local replicated = game:GetService("ReplicatedStorage")
local remote = replicated:WaitForChild("damageRemote")

remote:FireServer(<plr>, 10)

--This will damage the players health by 10 using a remote

Just a little example of how to use a remote, in this case the Player will be able to damage another Player

Here you have some links that will help you learn the usage of remote events and functions and how to use them.

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events https://www.youtube.com/watch?v=wic-N4JiFss&t=0s https://www.youtube.com/watch?v=4Dc_bri9mjs https://www.youtube.com/watch?v=C0qQ4lDa3t0&t=0s

This discussion is preserved as it was. New answers, comments, and votes are closed.