blox6137Join Date: 2008-11-23 Post Count: 1109 |
I have this script, that moves a model by clicking, but now it wont stop moving the model to where I click.
~~~~~
local littleSoldier = script.Parent
local click1 = Instance.new("ClickDetector")
click1.Parent = littleSoldier
local hum = script.Parent.Parent:FindFirstChild("Humanoid")
click1.MouseClick:connect(function(click)
local player = click
local click2 = player:GetMouse()
click2.Button1Down:connect(function(mouse)
hum:MoveTo(click2.hit.p)
end)
end)
~~~~~ |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
:/
Bump. |
|
UncleTazJoin Date: 2009-08-19 Post Count: 12795 |
xpcall (But I'm not experienced with that)
Or you can use a conditional statement. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Your script isn't going to work outside of studio you know, local scripts only run inside the player or the backpack/playergui
Or is your solider inside the player? |
|
UncleTazJoin Date: 2009-08-19 Post Count: 12795 |
:o
I have a idea but I'm going take a shower I'll share after this D: |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
@Uncle
local littleSoldier = script.Parent
local click1 = Instance.new("ClickDetector")
click1.Parent = littleSoldier
local hum = script.Parent.Parent:FindFirstChild("Humanoid")
click1.MouseClick:connect(function(click)
local player = click
local click2 = player:GetMouse()
click2.Button1Down:wait()
hum:MoveTo(click2.hit.p)
end)
Would be the way to fix it, although like I said, only for studio |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
O_O... It's not inside the player...
Yeah, I found out it doesn't work around 10 minutes ago... |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Do you still want it fixed? |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
I'd be most appreciative, but...
How does one determine if a script is local or not?
Does it matter where it is placed, or...?
Because I made a version of the script that was a child of the Workspace, but it still doesn't work in-game... |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
Local script are the ones from
Instance.new("LocalScript", Workspace)
Server scripts are
Instance.new("Script", Workspace)
In studio mode all scripts are ran as local, even server scripts, because your studio IS the server and the cleint |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
So I inserted a "server script" by instancing a new one, I then pasted the script in that server script, and placed it where the old one was after I deleted it...
Still not working. Am I missing something? |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
The players mouse can _not_ be used by a server script |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
I see. |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
I would suggest putting the click detector already in the object, and the local script in the startergui
It'd need to be rewriten, I can do that or you can try and I'll help fix it |
|
128GBJoin Date: 2014-04-17 Post Count: 8056 |
'It'd need to be rewriten, I can do that or you can try and I'll help fix it'
I'm sorry that was very rude
I'll help fix it if it does not work, I wasn't trying to say you can't do it. |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
Don't worry about it, I understood what you meant lol.
I'll work on a new script, and just post in the forums when I need help.
I don't want to be a burden. |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
I made the new script, and it works!
Thanks for all the help! |
|
UncleTazJoin Date: 2009-08-19 Post Count: 12795 |
I wish I didn't go take a shower D:
Can I test? |
|
blox6137Join Date: 2008-11-23 Post Count: 1109 |
I have the two soldiers I made at the game... I'll make my place copy-able so you could copy it and check it out... |
|