Hey there! I’m planning on working on another small project that is sorta like rock paper scissors. Basically, its goes normally, as rock beats scissors, paper beats rock, and scissors beat paper. However the biggest thing I need help with is playing an animation after the player chooses an option. So say the player would choose an attack, and the attack animation will play, along with damaging the other player. If two players choose the same attack, there would be an animation as well. Please tell me if this is not making much sense. Thanks for reading.
btw sorry for posting late. Won’t do it again I hope!
I understand what you mean. Do you have any code in place already to activate the animation? And what do you use to activate the animation? Ex. A gui button or clicking while holding an item.
I don’t script too often, so I wouldn’t know how to code any of this, meaning I did not already start with the coding. Nor are the animations ready since I’m planning on starting those tomorrow. Also I would rather use a GUI than a tool.
Do you have a development studio? Or do you want to do this on your own? I’ve never really worked for a development studio and I really wish to someday.
Alrighty, for activating the animation. If you have a local script inside of the button
(sorry, i dont know how to add the specific code part so ill just type it out)
–inside the local script (to play the anim)
local anim = game.workspace.Animation
local player = game.players.localplayer
local humanoid = player.Character.Humanoid
local animToPlay = humanoid:LoadAnimation(anim)
–to set up create the animation in the workspace, you can change the herratige if you want, but be sure to change it in the code as well if u do that
this is also just for the solo anim, for if players chose the same thing, it’ll have to have a remote event for each thing (rock paper and scissors) and tell if they fire at the same time through a server script which then sends it back to the local scripts to play a separate anim
I’d also like to point out that there are a few things wrong about Bootsthe1cat’s script.
It’s ‘LocalPlayer’, not ‘localplayer’,
You’d usually want to wait for the character’s Humanoid in order to not run into any errors.
You would want to parent the animation into ReplicatedStorage or into the folder rather than into the workspace for better organization.
--KEEP IN MIND, THIS WAS ONLY MADE WITH THE ROCK, DOUBLE NEARLY EVERYTHING FOR THE PAPER AND SCISSORS (EXCEPT FOR THE TIED AND CLEAN EVENTS)
--creating and naming the events
local rockEvent = Instance.new("RemoteEvent")
rockEvent.Parent = game.ReplicatedStorage
rockEvent.Name = "Rock Event"
local tiedEvent = Instance.new("RemoteEvent")
tiedEvent.Parent = game.ReplicatedStorage
tiedEvent.Name = "Tied Event"
local cleanEvent = Instance.new("RemoteEvent")
cleanEvent.Parent = game.ReplicatedStorage
cleanEvent.Name = "Clean Event"
--insert this part into both local and server scripts
local rockEvent = game.ReplicatedStorage:WaitForChild("Rock Event")
local tiedEvent = game.ReplicatedStorage:WaitForChild("Tied Event")
local cleanEvent = game.ReplicatedStorage:WaitForChild("Clean Event")
--this is on the local script
script.Parent.Activated:Connect(function()
rockEvent:FireServer() --or paperEvent or scissorEvent, depends on which button
end)
tiedEvent.OnClientEvent:Connect(function()
--play the tied anim
cleanEvent:FireServer()
end)
--we then run through a series of logic gates to check if two were fired at the same time (server script)
local rockNum = 0
rockEvent.OnServerEvent:Connect(function() -- do the same thing for paper and scissor, this checks if the event was fired and if it was fired once, sends a signal back to the player. With this system you'll probably also have to have another event fire at the end to clear everything.
if rockNum == 1 then
tiedEvent:FireAllClients()
rockNum = 0
else
rockNum = 1
end
end)
cleanEvent.OnServerEvent:Connect(function()
rockNum = 0 --also set all other nums, paperNum and scissorNum to 0
end)
i haven’t had the time to test this so lemme know how it goes
A couple of questions.
Here is what I put in each script, with the animation ID changed for each.
Here is where everything is
And here is the result
(apologies for the lag. My computer acts up when I screen record.)
Not sure if I put anything in the wrong place, or edited the script the wrong way, but nothing is working.
Another question, not sure where to put the tied script, or what kind of script to put it in. I also have no idea if I should edit the script. If so, what would I change.
Sorry I made this message so late, just didn’t have much time to use studio. Thanks!
And for the animaton, insert the Animation part into workspace or wherever you stored it. And change the herratage in Anim to where you stored that anim. I’ll send a pic once I can get on Studio