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

Unable to cast to dictionary?

So i'm making a fire ball and i'm scripting it so when it hits something it expands in size and then disappears. I'm using the TweenService for this and it comes back with an error saying "Unable to cast to dictionary". I then tried to use the pcall function to see if it would work but no it didn't. I don't understand, any help?

Here is my script.

game.ReplicatedStorage.Events.FireBallEvent.OnServerEvent:Connect(function(plr)
	local fire = Instance.new("Part")
	fire.Parent = workspace
	fire.Shape = "Ball"
	fire.Material = Enum.Material.Neon
	fire.CFrame = plr.Character.UpperTorso.CFrame
	fire.Size = Vector3.new(4,4,4)
	fire.CanCollide = false
	fire.BrickColor = BrickColor.new("Bright yellow")
	fire.Anchored = false
	local bv = Instance.new("BodyVelocity",fire)
	bv.Velocity = plr.Character.UpperTorso.CFrame.LookVector.Unit * 50
	bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	if fire.Parent == workspace then
		local tween = game:GetService("TweenService")	
		local tweeninfo = TweenInfo.new(
		1,			
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out,
		0,
		false,
		1)
		local properties = {
		Size = Vector3.new(10,10,10)
		}		
		local create = tween:Create(tweeninfo,properties,fire)
		fire.Touched:connect(function(hit)
		create:Play()
	if hit.Parent:FindFirstChild('Humanoid') then
		local player = game.Players:GetPlayerFromCharacter(hit.Parent)
		if player then
			return nil
		else
			hit.Parent.Humanoid:TakeDamage(5)
					end
				end	
			end)
		if fire.Parent == workspace then
		wait(3)
		fire:Destroy()
		end
	end
end)

1 answer

✓ Accepted answer

You are giving the correct Parameters to the Tween:Create, just in the wrong order. In total it takes 3 different parameters in the following order:

Part - This is the actual part you want to apply the tween to. Keep in mind, this has to be one singular part and cannot be a model.

TweenInformation - This is TweenInfo which can be specified by making use of TweenInfo.new

Properties - These are the final property changes you want to showcase during the tween. If you are only doing one change, I normally would have this inserted directly into the Tween:Create to save defining another variable.

So, to fix your error, you need to alter line 26 to this:

local create = tween:Create(fire, tweeninfo, properties)

Also just another side note, when you are creating a Connection with a event, capitalise the C as the lowercase version of this is depreciated. Your code will still work but it is good practice to get into. Example code below:

game.Players.PlayerAdded:Connect(function()

end)

1 comment

0

Thank you so much!

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