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

Why me event dosent work with instances?

game:GetService("RunService").RenderStepped:Connect(function()
	if MD and DB then
		DB = false
		
		script.Shoo:FireServer(weapon.Hit.shoot, weapon.Hit.CFrame.p, Mouse.Hit.p)
	end
end)

this is the local script

local DB = false

script.Parent:WaitForChild("FPS").TakeDamage.OnServerEvent:Connect(function(Plr, Sound, P1, P2)
		Sound:Play()
		
		local ray = Ray.new(P1, (P2 - P1).unit * 300)
		local part, position = workspace:FindPartOnRay(ray, Plr.Character, false, true)
		
		local beam = Instance.new("Part", workspace)
		beam.BrickColor = BrickColor.new("Cool yellow")
		beam.FormFactor = "Custom"
		beam.Material = "Neon"
		beam.Transparency = 0.25
		beam.Anchored = true
		beam.Locked = true
		beam.CanCollide = false
		
		local distance = (P1 - position).magnitude
		beam.Size = Vector3.new(0.05, 0.05, distance)
		beam.CFrame = CFrame.new(P1, position) * CFrame.new(0, 0, -distance / 2)
		
		if part then
			if part.Parent:FindFirstChild("Humanoid") then
				local mag = (P1 - part.Position).magnitude
				
				part.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(16, 20) - (mag / 10))
			elseif part.Parent.Parent:FindFirstChild("Humanoid") then
				local mag = (P1 - part.Position).magnitude
				
				part.Parent.Parent:FindFirstChild("Humanoid"):TakeDamage(math.random(16, 20) - (mag / 10))
			end
		end
		
		--[[local Mag = game.ReplicatedStorage.Mag:Clone()
		Mag.Parent = workspace.Mags
		Mag.CFrame = weapon.Body.MagDrop.WorldCFrame
		
		local Effect = game.ReplicatedStorage.Effect:Clone()
		Effect.Parent = workspace.Mags
		Effect.CFrame = Mouse.Hit]]
		
		game:GetService("Debris"):AddItem(beam, 0.001)
		wait(.05)
		DB = true
		
		--[[wait(4)
		Effect:Destroy()
		Mag:Destroy()]]
end)

this is script

i cant use instances like Sound objects and but not cframe and positions and bools numbers etc. thanks

1 answer

✓ Accepted answer

On line 3 on the local script, it says OnServerEvent but you aren't on the server.

1 comment

0

I mean the event dosent let me use instances i dont say it is brocken i can use bool int and values

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