generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Scripting Help

Previous Thread :: Next Thread 
Stephanie_Angela is not online. Stephanie_Angela
Joined: 28 Oct 2016
Total Posts: 55
07 Jan 2017 06:02 AM
So I created a part where it gives you moneys when you hold left click. For some reason, it won't work. I already called my event, so that isn't the problem. Please take a look:

Script:

mouse = Player:GetMouse()
Player = game.Players.LocalPlayer

script.Parent.ClickDetector.Button1Down:connect(function()
wait(5)

Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 50

local char = game:GetService("Players").LocalPlayer.Character
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset?id=602515737"
local animationTrack = char:WaitForChild("Humanoid"):LoadAnimation(animation)
animationTrack:Play()
mouse.Button1Up:connect(function()
animationTrack:Stop()
end)


end)

Much help is appreciated.
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 06:05 AM
"script.Parent.ClickDetector.Button1Down:connect(function()
wait(5)"

Button1down isnt a thing fro clickdetector.

You want mouseclick.

script.Parent.ClickDetector.MouseClick:connect(function()
wait(5)
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 06:07 AM
game.Players.LocalPlayer wont work aswell as this is a serverscript. It will work in test but will not work in game.

Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 06:09 AM
script.Parent.ClickDetector.MouseClick:connect(function(player)
wait(5)

player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 50

local char = player.Character
end)

Animations I think need to be played locally aswell

Report Abuse
Stephanie_Angela is not online. Stephanie_Angela
Joined: 28 Oct 2016
Total Posts: 55
07 Jan 2017 06:13 AM
I am a little confused. I want it to hold it so that it plays the animation, instead of clicking. I am pretty sure it has something to do with Button1Down?
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Jan 2017 06:15 AM
There's quite a bit wrong with this. Let's start at the beginning I guess:

-> LocalScripts will not run as a descendant of anything in Workspace other than your Character, which leads me to assume this is not a LocalScript.
-> You cannot access the LocalPlayer (much less a client's mouse) from a Script, not only that but you attempted to use the Player variable before defining it (order matters).
-> ClickDetectors do not have a Button1Down event, rather it's MouseClick.
-> That animation is not yours, so you are not going to be able it. Again, I'll assume this is your alt. account and you have access to said animation.
-> I believe the MouseClick event is just that, for clicks. Testing for their Mouse to come up may be rather annoying. You could just not using ClickDetectors which would probably be a better idea.
Another problem, but not reason the script is not working, is the lack of a debounce.

In the end, what you're going to want to do is handle this all from a LocalScript. If FE is enabled you will be required to increment the LocalPlayer's money from the server as well. I'm under the assumption FE is not currently enabled, so try placing the folllowing in a LocalScript:

local player = game:GetService("Players").LocalPlayer
local money = player:WaitForChild("leaderstats"):WaitForChild("Money")
local character = player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset?id=602515737"
animation.Parent = humanoid -- not sure if this is required
local animationTrack = humanoid:LoadAnimation(animation) -- no need to call LoadAnimation every time, we can just re-play an AnimationTrack.
local clickDetector = workspace.Part.ClickDetector -- you may have to change this
local enabled = true -- debounce
clickDetector.MouseClick:connect(function()
if not enabled then return end -- do nothing if active
enabled = false
money.Value = money.Value + 50
animationTrack:Play()
wait(5)
animationTrack:Stop()
enabled = true
end)

Of course this may not be exactly what you want (nor have I tested the code) but hopefully it'll help you understand what your problems were.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
07 Jan 2017 06:15 AM
That animation is not yours, so you are not going to be able to use it*
Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 06:21 AM
http://wiki.roblox.com/index.php?title=API:Class/ClickDetector

Nothing called Button1Down

You might want to use MouseHoverEnter Instead.

Try this, put this localscript under starterplayerscripts.

Rename the part to anim

local part = game.Workspace:WaitForChild("Part")
part.ClickDetector.MouseHoverEnter:connect(function(player)
wait(5)

player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 50

char = player.Character
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset?id=602515737"
local animationTrack = char:WaitForChild("Humanoid"):LoadAnimation(animation)
animationTrack:Play()
end)

part.ClickDetector.MouseHoverLeave:Connect(function(player)
-- stop the animation from here


Report Abuse
KritikalGunzz is not online. KritikalGunzz
Joined: 10 Nov 2013
Total Posts: 1633
07 Jan 2017 06:23 AM
local part = game.Workspace:WaitForChild("anim")
Report Abuse
Stephanie_Angela is not online. Stephanie_Angela
Joined: 28 Oct 2016
Total Posts: 55
07 Jan 2017 06:56 AM
Ehh, thank you everyone for your efforts, but it's just not working. I will try and use your knowledge to improve my scripting. For now, I might as well look through free models.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image