I want to create a wand with special abilities (need help)

So, I have been working on a wand for my game but I’m new in scripting and could use some tips.

I want to create my wand so I can choose which spell I want to cast from it. I have tried by my self but I’m not that good with remote functions.

I have already created one of the spells but I can’t figure out how to place it in the spell-wheel where you can choose your spell.

Btw I also want to create a way to buy the spells you can choose from for Exp or something.

Do you have any suggestions? :smiley:

3 Likes

Hi! Assuming you want to pick a particular spell from a clickable GUI or something like that, you could have a string value object inside of a player. You could do this by inserting the string value inside of a player as soon as it joins for example:

game.Players.PlayerAdded:Connect(function(player)
local spellChosen = Instance.new(StringValue, player)
spellChosen.Name = “SpellChosen”
end)

So then you select the type of spell you want to cast through a number of different GUI buttons (which represent the different spells). Each spell GUI button has a script in it, so when you click it, in that particular script, (lets say you had a “Cast Fire” button that you pressed) it would set the spell chosen value to CastFire (the value that was parented to the player when it joined).

Then you could have a script inside of the tool set up so when you click (through Tool.Activated), depending on the SpellChosens value, (or if it would just not do anything) it would then send a remote event to the server, casting the spell.

Just something I thought of, there might be a more efficient method out there, I am unsure.

3 Likes

Sounds great. I will try it out :smiley:

1 Like

Ok, it worked.

But I need to be able to select more than one spell.

Here is my script for detecting and foreign the event:

wait(1)
---- Services ----
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local UserInputService = game:GetService(“UserInputService”)

---- Variables ----
local IceRemote = ReplicatedStorage:WaitForChild(“IceRemote”)
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Handle = script.Parent.Handle
local Light = script.parent.Light
local SpellOffset = script.Parent.SpellOffset
local spellChosen = script.Parent.Parent.Parent:FindFirstChild(“SpellChosen”)
local Humanoid = Character:WaitForChild(“Humanoid”)
local AttackAnimation = Instance.new(“Animation”) – create a new animation object
AttackAnimation.AnimationId = “rbxassetid://4966082049” – put your animation id over the zeroes

---- Settings ----
local CoolDown = true

local tool = script.Parent

local function onEquip()

wait(0.5)

Handle.Transparency = 0
Light.Transparency = 0.3
SpellOffset.Transparency = 0.5

end

local function onUnequip()

Handle.Transparency = 1
Light.Transparency = 1
SpellOffset.Transparency = 1

end

local function onActivate()

if CoolDown then
	
	
	if spellChosen.Value == "Ice" then
	

	local AttackAnimationStart = Humanoid:LoadAnimation(AttackAnimation)
	AttackAnimationStart:Play() -- Starts Attackanimation
	
	wait(0.5)
	
	AttackAnimationStart:Stop()
	
	IceRemote:FireServer()
	local newLight = Instance.new("SpotLight",script.Parent.Light)-- Creates the "Spotlight"
	newLight.Brightness = 17 -- The brightness of the "Spotlight"
	newLight.Range = 12 -- Range of the "Spotlight"
	newLight.Face = "Top" -- Tells there the "Spotlight" faces
	
		CoolDown = false -- /Cooldown in 8 seconds
		
	wait(8)
			
		CoolDown = true -- Cooldown is over
		
	end
	end

end

local function onDeactivate()

wait(0.2)

	script.Parent.Light:FindFirstChild("SpotLight"):Destroy() -- After 0.2 seconds "Spotlight" is destroyed

end

tool.Equipped:Connect(onEquip)
tool.Unequipped:Connect(onUnequip)
tool.Activated:Connect(onActivate)
tool.Deactivated:Connect(onDeactivate)

So, if the ice spell isn’t chosen I want the script to move on and detect if another spell is chosen.

Do you have any suggestions? :smiley:

1 Like

I solved it by using “else”.
The only problem I got now is how I can open the spell-wheel

I want to make a user-input (E) and to open the spell-wheel (GUI) you have to hold “E” and if you stop holding the key the spell-wheel will close

Do you have any suggestions? :smiley:

This place isn’t helpful for you to get people to do the coding for you - if you’d like that, go to #collaboration:recruitment

You should spend some time debugging your code, and making the attempt yourself - then, if you still can’t, come back with an error or specific issue that will make it easier for people to give you a specific answer, not coding advice.

1 Like

So would it be better to not answer questions like these (like the one TheDeadTed14 asked)?
I am also new to the devforum so I am still figuring things out here…

1 Like

I think that what @EllipticCurve_DHE was referring to was how when he solved the first problem with your help he asked another question right after essentially asking you for tips on UserInput. This was not included in the original post as an issue and there are many resources and Youtube videos about detecting UserInput. For example, here is a video E to interact. Watching this video you can change the code up a bit to accomplish the task you’re aiming for. You could look up many different resources for the specific purpose of using E to interact or whatever key you choose for that matter. He is not saying do not answer these questions, but simply informing the poster that there are other things to try before posting something here. Have a great day!

3 Likes

Thanks for the reply! You to :grinning:

2 Likes