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

Make this confusing script server sided easily?

I've been trying to make this server sided but I'm unable to do so I've tried for about an hour or two trying to fix this..

local Debounce = false
local MultDiv = 5
script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and not Debounce then
		local hum = hit.Parent:WaitForChild("Humanoid")
		
		game.ReplicatedStorage.ScreenGui:Clone().Parent = game.Localplayer.plr.PlayerGui
		hum:remove()
		Debounce = true
		wait(3)
		print("Scumbag named " + Localplayer.Name + "was removed.")
		Debounce = false
	end
end)

2 answers

✓ Accepted answer

You can't use LocalPlayer in a server script, do this:

local Debounce = false
local MultDiv = 5
script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") and not Debounce then
        local hum = hit.Parent:WaitForChild("Humanoid")
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        game.ReplicatedStorage.ScreenGui:Clone().Parent = plr.PlayerGui
        hum:remove()
        Debounce = true
        wait(3)
        print("Scumbag named " + plr.Name + "was removed.")
        Debounce = false
    end
end)

Hm, I don't get what you're trying to do here.

I believe you're going to be using a standard script for this code, I don't know why you want to convert it to FilteringEnabled.

And if that's not what you're trying to do here's the definition of Server-Sided script:

Script that runs on the server instead of the client, often used in Roblox to prevent any unauthorized changes made by the client when used in FilteringEnabled.

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