Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does my script not work on Filter enabled servers?

Asked by 6 years ago

I making this gun and it works perfectly in Studio but when in a server with a friend my friend can't see my bullets and killing each other doesn't work.

Could someone explain to me how to make my script work in servers (I used a local script)

001-- Starting stuff --
002local tool = script.Parent
003local player = game.Players.LocalPlayer
004local mouse = player:GetMouse()
005local character = player.Character
006local Barrel = tool:WaitForChild("Barrel")
007local enabled = true
008local Ammo = tool:WaitForChild("Ammo")
009local ammo = Ammo.Value
010local SA = tool:WaitForChild("StoredAmmo")
011local StoredAmmo = SA.Value
012local Reloading = false
013 
014--Shooting--
015function Shoot()
View all 187 lines...
0
it would be nice if u pinpointed your problems before posting 200 lines of code Gey4Jesus69 2705 — 6y
0
if you knew enough to write this you'd also know how filtering enabled worked. DinozCreates 1070 — 6y
1
I got to agree with gioni01 you could have been a little more specific but filtering enabled means that local scripts cannot effect things within the game like workspace, only server scripts can. When you turn filtering enabled off then exploiters can break your game really bad with running local scripts that effect your game VoltiCoio 19 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Because its in a local script it wont work with filtering enabled and all of the shooting part would have to be run through a server script. There's a few ways you could do it and I am new to this so i don't know the best way but a Remote event would most likely work for this.

For example:

01--LocalScript
02--CODE
03mouse.KeyDown:Connect(function()
04    game:GetService("ReplicatedStorage").[bulletRemoteEventName]:FireServer() --Fires the remote event and triggers it in the server script
05 end)
06 
07--ServerScript
08game:GetService("ReplicatedStorage").[bulletRemoteEventname].OnServerEvent:Connect(function() --Hears out for the event and connects to a function
09    --Code for bullet shooting
10 end)

You can research this a little more here- https://developer.roblox.com/api-reference/class/RemoteEvent

0
I don't think that there is a need for a "." after "game:GetService("ReplicatedStorage")" OptimisticSide 199 — 6y
Ad

Answer this question