0

# [Solved] I have working script but when i changed to LocalScript it wont work (?)

Edited by imKirda 13 days ago

MoveTo Script:

local NPC = script.Parent
local part1 = game.Workspace.Part1

while true do
NPC.Humanoid:MoveTo(part1.Position)
wait(0.5)
end



Touching Teleport & Killing:

local dum = game.Workspace.Dummy
game.Workspace.Dummy.Hitbox.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(0,0,0))
hit.Parent.Humanoid.Health = 0
end
end)


Basic Animation:

local animation = script:WaitForChild('Animation')
local humanoid = script.Parent:WaitForChild('Humanoid')
dance:Play()

while wait(0.5) do
dance:Play()
end


These are all of my codes, they work well they have no problem until i changed to a LocalScript. Should i do other stuff to convert to LocalScript or anything ? What should i do or what tutorials i need to watch ?

0
Some of your scripts aren't supposed to be LocalScripts, I can tell you that for sure. Can you provide any error messages or does your code not output any? iiMxtt_Destinyii 58 — 15d
0
The Animation script is supposed to be a LocalScript but your MoveTo and Teleport/Killing should be server sided otherwise, your only affecting your client and not others. iiMxtt_Destinyii 58 — 15d
0
You shouldn't use while true do also because, it's going to repeat it over and over again which may cause performance issues. iiMxtt_Destinyii 58 — 15d
0
1. No i dont have any error massage. xFurkanToDie 4 — 15d
0
2. Okey im gonna explain my game purpose. xFurkanToDie 4 — 15d
0
Its simple obby game but your chasing by npc, if npc catch you you will die and all your checkpoints are resets. So i want that npc client side, i mean if someone join later npc cant chase him right ? because npc far away from start (correct me if im wrong) so yeah how im gonno do that xFurkanToDie 4 — 15d
0
Ah okay, yeah yeah. I get you. Do you want me to write you some scripts that will be client sided? iiMxtt_Destinyii 58 — 15d
0
Well if its helpful it would be great xFurkanToDie 4 — 15d
0
Alright, I'll fix some up rn iiMxtt_Destinyii 58 — 15d
0
Mate im going to sleep, its 04,34 AM in my country. If you know any tutorial to solve my problem please post here. Good Night. xFurkanToDie 4 — 15d
0
I'll leave them attached to the post then you can see them tomorrow but, I'll look for a tutorial for you too. iiMxtt_Destinyii 58 — 15d
0
Hi dude i woke up for school, did you find anything ? btw Good Morning xFurkanToDie 4 — 15d
0
Why do you change it in the first place? Localscript are usually use for camera manipulation, mouse manipulation, gui manipulation and etc realchricrocgamer 0 — 13d
0
Because i want to make client side npc and i thought i should use local script for that am i wrong ? xFurkanToDie 4 — 13d

0

Local Scripts only work inside - Player's Character Scripts - Player's GUI - Player's Scripts

0
oh okey how can i do client side npc xFurkanToDie 4 — 14d
0
Well, I mean you can always control it using scripts in the Player Starter GUI MineBlox_Artz 50 — 14d
0
Can you explain a little bit please ? xFurkanToDie 4 — 14d
0
For example put the Move Script in StarterGUI and instead of script.Parent, put the workspace position of npc MineBlox_Artz 50 — 14d
0
i did but it didnt work xFurkanToDie 4 — 14d
0
In the MoveTo Script i changed NPC = script.Parent to NPC = game.Workspace.Dummy and i changed to localscript to but still doesnt work xFurkanToDie 4 — 14d
0
And did you put it in the StarterGUI, also remember. MoveTo teleports instantly MineBlox_Artz 50 — 14d
0
yeah i put in starter gui xFurkanToDie 4 — 14d
0
it should work then. MineBlox_Artz 50 — 14d
0
If you have time you can try yourself xFurkanToDie 4 — 14d
0
game.ReplicatedStorage.Dummy:Clone().Parent = game.Workspace