I have a laser gun, and I am trying to make it work with FilteringEnabled. When I try to use it, it puts in the output 21:02:54.742 - TeamColor is not a valid member of WedgePart 21:02:54.743 - Script 'Workspace.FireLaser.Script', Line 8 21:02:54.744 - Stack End 21:02:54.745 - TeamColor is not a valid member of WedgePart 21:02:54.746 - Script 'Players.Player1.Backpack.Lazer Beam.LocalScript', Line 41 21:02:54.747 - Stack End when I click on a wedge. It says Part instead of WedgePart when I click on a part. Here is the main code for the laser gun:
--Other unrelated code local user = tool.Parent local person = game.Players:GetPlayerFromCharacter(user) local Gui = person.PlayerGui.AmmoGui function onClick() click = true while click do if Debounce == false then Debounce = true if Gui.Energy.Value > 0 then Gui.Energy.Value = Gui.Energy.Value - 1 Gui.Frame.TextLabel.Text = Gui.Energy.Value tool.Handle.LazerBoom:play() local ray = Ray.new(tool.Handle.CFrame.p, ((mouse.Hit.p + Vector3.new((math.random(-100, 100)/100), (math.random(-100, 100)/100), (math.random(-100, 100)/100))) - tool.Handle.CFrame.p).unit*300) local hit, position = game.Workspace:FindPartOnRay(ray, user) local distance = (position - tool.Handle.CFrame.p).magnitude --Line 41 below V local isFired = game.Workspace.FireLaser:InvokeServer(game.Workspace:FindPartOnRay(ray, user), person, (position - tool.Handle.CFrame.p).magnitude, CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)) repeat wait() until isFired == true wait(0.15) else script.Parent.Handle.NoEnergy:play() click = false end Debounce = false end end end --More unrelated code
And the RemoteFunction:
function script.Parent.OnServerInvoke(hit, person, distance, CFrameValue) local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then humanoid:TakeDamage(10) end local rayPart = Instance.new("Part", user) rayPart.Name = "RayPart" rayPart.BrickColor = person.TeamColor rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrameValue game.Debris:AddItem(rayPart, 0.1) end
Sorry if I am making an obvious mistake, I just started with RemoteObjects.
Two tips:
You can use game.Players.LocalPlayer
to get the Client's associated Player from a LocalScript.
The basic syntax for RemoteEvents is such:
--Server local Event = game.ReplicatedStorage.Event Event.OnServerEvent:connect(function(player, params) --Note the `player` parameter Event:FireClient(player, params + 1) end) --Client local Event = game.ReplicatedStorage.Event Event.OnClientEvent:connect(function(params) --Note the lack of `player` print(params) end) Event:FireServer(1) --Again, note the lack of `player`
These two scripts together (assuming Event exists) will print 2
in the Client's Output.