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

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

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')
local dance = humanoid:LoadAnimation(animation)
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 ?

14 comments

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?

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.

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.

0
  1. No i dont have any error massage.
0
  1. Okey im gonna explain my game purpose.
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

0

Ah okay, yeah yeah. I get you. Do you want me to write you some scripts that will be client sided?

0

Well if its helpful it would be great

0

Alright, I'll fix some up rn

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.

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.

0

Hi dude i woke up for school, did you find anything ? btw Good Morning

0

Why do you change it in the first place? Localscript are usually use for camera manipulation, mouse manipulation, gui manipulation and etc

0

Because i want to make client side npc and i thought i should use local script for that am i wrong ?

2 answers

Local Scripts only work inside

  • Player's Character Scripts
  • Player's GUI
  • Player's Scripts

10 comments

0

oh okey how can i do client side npc

0

Well, I mean you can always control it using scripts in the Player Starter GUI

0

Can you explain a little bit please ?

0

For example put the Move Script in StarterGUI and instead of script.Parent, put the workspace position of npc

0

i did but it didnt work

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

0

And did you put it in the StarterGUI, also remember. MoveTo teleports instantly

0

yeah i put in starter gui

0

it should work then.

0

If you have time you can try yourself

I think i solved my problem, thanks for realchricrocgamer to solving my problem here how i solved:

I put dummy in ReplicatedStorage, i put my scripts in StarterGUI, i cloned like that:

game.ReplicatedStorage.Dummy:Clone().Parent = game.Workspace

And thats it i solved like that. Thank you again realchricrocgamer.

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