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

How to make a local script into a working server script?

What I'm trying to do is make my local script into a working server script.

local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local UserInputService = game:GetService("UserInputService") local Key = "E" local Visible = true local function Visibility(Var) if Var then for _, Part in pairs(char:GetDescendants())do if Part:IsA("BasePart") or Part:IsA("MeshPart") then Part.Transparency = 0 char.Head.face.Transparency = 0 char.HumanoidRootPart.Transparency = 1 end end else for _, Part in pairs(char:GetDescendants())do if Part:IsA("BasePart") or Part:IsA("MeshPart") then Part.Transparency = 1 char.Head.face.Transparency = 1 end end
end end UserInputService.InputBegan:Connect(function(Input,GameStuff) if GameStuff then return end if Input.KeyCode == Enum.KeyCode[Key] then if Visible then Visibility(false) Visible = false else Visibility(true) Visible = true
end end end) game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function(Character) for i,Child in pairs(Character:GetChildren()) do if Child:IsA('Part') or Child:IsA('MeshPart') then Child.Transparency = 1 end end wait(2) for i,Child in pairs(Character:GetChildren()) do if Child:IsA('Accessory') then Child:Destroy() end end Character.Head.face:Destroy() end) end)

1 comment

0

please fix this and put it into a block of code

1 answer

✓ Accepted answer

it isnt possible for a client to access server storage and server script storage, thats why its good to put server scripts in them if you can, I dont understand what you are trying to do, please explain more

Edit: Ok i underatand what your doing, you want to make server changes, but it can only be detected by the client, you use remove events for that. Remote events send information from client to server and from server to client by Firing a remote event, a server script can easily capture it using remoteevent.OnServerEvent:Connect(fcuntion(), Learn more about remote events, its actually pretty easy, you just insert a remote event in replicatedStorage, and from local script, call it with FireServer(), and receive it with server script with OnServerEvent, and then you can make server changes like that. READ AND LEARN PLS https://developer.roblox.com/en-us/articles/Remote-Functions-and-Events

4 comments

0

What I'm trying to do is make my local script into a working server script.

0

why not just make it a server script form the beginning? just copy the code from the local script, create a server script, and paste that code in and fix it, and somethings you cant fix like game.Players.LocalPlayer because its not local, its server, which in that case you would use remote events to talk from the serevr to the client

0

Thanks for the help, I'm going to go learn about remote events now.

0

:)

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