-- this is the client sided version of the script, which is what im making into a serversided version
local RunService = game:GetService("RunService")
local npc = workspace.NPC
local character = game.Players.LocalPlayer.Character
RunService.RenderStepped:Connect(function()
local npcToCharacter = (character.Head.Position - npc.Head.Position).Unit
local npcLook = npc.Head.CFrame.LookVector
local dotProduct = npcToCharacter:Dot(npcLook)
if dotProduct > 0.5 then
workspace.Baseplate.BrickColor = BrickColor.new("Medium red")
else
workspace.Baseplate.BrickColor = BrickColor.new("Medium green")
end
end)
--the script on the server that isnt working
game.Players.PlayerAdded:Connect(function(player)
local RunService = game:GetService("RunService")
local npc = workspace.NPC
local character = player.Character
RunService.RenderStepped:Connect(function()
local npcToCharacter = (character.Head.Position - npc.Head.Position).Unit
local npcLook = npc.Head.CFrame.LookVector
local dotProduct = npcToCharacter:Dot(npcLook)
if dotProduct > 0.5 then
workspace.Baseplate.BrickColor = BrickColor.new("Medium red")
else
workspace.Baseplate.BrickColor = BrickColor.new("Medium green")
end
end)
end)
You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I’m trying to make the client sided script work on the server -
What is the issue? Include screenshots / videos if possible!
Whenever i do it in the server it will just do nothing, i dont get any errors or anything, nothing happens at all. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
The current script I’m using is after a bunch of attempted solutions like changing the variables and such to work in the server, but it still doesn’t work and I don’t see anything wrong with the script. I’ve looked for solutions on the dev hub but none of the ones I found fit with what I’m trying to do.
another little piece of info, is that i got the local one from this video and thought it would be useful on the server but I just can’t seem to convert it over.