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

How Do I make touch event fire from a local brick for other player in mine script?

So Im making a mine script and here's my LOCAL SCRIPT

local plr = game.Players.LocalPlayer
local char = plr.Character
local Mouse = plr:GetMouse()
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Remotes = ReplicatedStorage:WaitForChild("RemoteEvent")

Mouse.Button1Down:Connect(function()
	local Part = Instance.new("Part")
	Part.Parent = workspace
	Part.Anchored = true 
	Part.Position = Mouse.Hit.p
	Part.Touched:Connect(function(touch)
		EHum = touch.Parent:FindFirstChild('Humanoid') 
		if EHum and not plr.Character.Humanoid then
			Remotes:FireServer(Part.Position,Part)
			
		end
	end) 
	
end)



And then here's my

SEVERSCRIPT

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild('RemoteEvent')
local Debounce = false 
RemoteEvent.OnServerEvent:Connect(function(player,partposition)
	Explosion = Instance.new("Explosion")
	Explosion.Parent = workspace
	Explosion.Position = partposition
	Explosion.DestroyJointRadiusPercent = 0
	Explosion.Hit:Connect(function(hit,distance)
		EnemyHumanoid = hit.Parent:FindFirstChild('Humanoid')
		if EnemyHumanoid and not player.Character.Humanoid then
			if Debounce == true then return end
			if Debounce == false then
			EnemyHumanoid:TakeDamage(20)
			print('gay')
			Debounce = true 
			
		end
		end
		
	end)
	
	
end)

1 comment

0

Can you be more clear with your question? What are you trying to accomplish. Give a DETAILED explanation. Also, why the heck are you printing "gay"

1 answer

If you are trying to fire an event with a brick when it is touched, you don't use the Button1Down feature.

This code may possibly solve your issue

Local Script: .~~~~~~~~~~~~~~~~~ local plr = game.Players.LocalPlayer local char = plr.Character local Mouse = plr:GetMouse() local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remotes = ReplicatedStorage:WaitForChild("RemoteEvent")

script.Parent.Touched:connect(function(hit) local Part = Instance.new("Part") Part.Parent = workspace Part.Anchored = true Part.Position = Touched.Hit.Position Part.Touched:Connect(function(touch) Hum = touch.Parent:FindFirstChild('Humanoid') if Hum and not plr.Character.Humanoid then Remotes:FireServer(Part.Position,Part) end end) end)

ServerScript should work fine as long as it is in ServerScriptService.

Hope this works.

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