So I have a server script that spawns in a part called BEAM when shootEvent is called.
Normally, since I am creating the part in a server script, everyone can see it.
But what I want to happen is, I want everyone to be able to see the BEAM except for the player that called that event.
Not only do I want the player who called the event, not to be able to see the BEAM. But I also want the player that called the event to create his own BEAM that only he can see.
You can use a remote event.
-- Server
local re = Instance.new("RemoteEvent",workspace)
-- use to command 1 client re:FireClient(player,beaminfo)
-- Create a list of all the players besides the caster
local plrs = game.Players:getChildren()
table.remove(caster)
for i,v in ipairs(plrs) do
re:FireClient(v,regularBeaminfo)
end
re:FireClient(caster,casterBeaminfo)
-- local
re.OnClientEvent:connect(function(beaminfo)
-- spawn a beam using beaminfo
end)
So currently, there is only one player that can possibly fire the event so I dont need a table or anything.
There is a separate server script and local script for each player
Well no, you do need that, because you want to show a beam to most players but not to 1. If you just do it over the server, the 1 will see the other beam anyways. I guess you can destroy it on their client, but this is definitely cleaner
Sorry I am having a little trouble understanding the script you wrote.
Here is my current local script
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local mouse = player:GetMouse()
local tool = script.Parent
local UIS = game:GetService("UserInputService")
local reloadEvent = tool:WaitForChild("reloadEvent")
local shootEvent = tool:WaitForChild("shootEvent")
tool.Activated:Connect(function()
shootEvent:FireServer(mouse.Hit.Position)
end)
UIS.InputBegan:Connect(function(input, isTyping)
if input.KeyCode == Enum.KeyCode.R then
reloadEvent:FireServer(input.KeyCode, isTyping)
end
end)
Create a server script. Create a remote event object called castBeam.
In the script, declare the remoteevent (that is to say, define a variable which points towards the remote event object).
Then simply implement my code, exchanging ‘re’ for your remote event.
The local part should be in a client script.
table.remove(caster) doesnt work also what is BeamInfo supposed to be?
Well yes, the code isn’t functional. It’s just a guide for you. And that should be ‘table.remove(plrs,caster)’
You want to create different beams. I assume you have a table with properties. That’s beaminfo.
No, it is the same exact beam. The reason why I need two different instances of the beam, separate for the client and the rest of the server is because I am trying to mask a raycast delay
Well then you can just ignore beaminfo
OHHHH I get it know, OMG that makes so much sense now. All I have to do is fire the remote event and in the parameter’s I just put the players I want to see the beam, thank you for being patient with me lol
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.