Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Mouse.Hit.p Doesn't work with TweenService?

Asked by
Zero_Tsou 175
4 years ago
Edited 4 years ago

So i was making a fireball script for cool stuff( using remote )

LocalScript:

local FireBall = game.Workspace.FireBall
local rp = game:GetService("ReplicatedStorage")
local FireBallRemote = rp.RemoteEvents.FireBall
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local mousehit = player:GetMouse().Hit.p

UIS.InputBegan:Connect(function(input, IsTyping)
    if IsTyping then
        return

    elseif input.KeyCode == Enum.KeyCode.E then
        FireBallRemote:FireServer(player, mousehit)
    end
end)

ServerScript:

local FireBall = game.Workspace.FireBall:Clone()
local rp = game:GetService("ReplicatedStorage")
local FireBallRemote = rp.RemoteEvents.FireBall
local UIS = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

FireBallRemote.OnServerEvent:Connect(function(player, mousehit)
    local Character = player.Character
    local HumanoidRootPart = Character.HumanoidRootPart
    local Align = Instance.new("AlignPosition")
    Align.Enabled = false
    Align.Parent = HumanoidRootPart
        Align.Attachment0 = HumanoidRootPart.RootRigAttachment
    Align.Attachment1 = FireBall.FireBallAttachment
    Align.RigidityEnabled = true
    FireBall.Parent = Character
    FireBall.CFrame = HumanoidRootPart.CFrame * CFrame.new(0,45,0)
    ------------tween2-------------------
    local info1 = {}
    info1.Size = FireBall.Size + Vector3.new(30,30,30)
    local info12 = TweenInfo.new(7, Enum.EasingStyle.Quad)
    local tween2 = TweenService:Create(FireBall,info12, info1)



    -------------tween-------------
    local info = {}
    info.CFrame  = mousehit --- the issue
    local info6 = TweenInfo.new(7 ,Enum.EasingStyle.Quint )
    local tween1 = TweenService:Create(FireBall, info6, info) -- the issue
    tween2:Play()
    Align.Enabled = true
    wait(7)
    tween2:Pause()
    wait(1)
    Align.Enabled = false   
    tween1:Play()
end)

As you can see there i was trying to set the CFrame value of the tween to the Mouse.p I checked and clicked "E" This is what the Output said D:,

Output:

** 18:08:26.645 - TweenService:Create property named 'CFrame' cannot be tweened due to type mismatch (property is a 'CoordinateFrame', but given type is 'Instance') 18:08:26.661 - Script 'ServerScriptService.FireBallHandle', Line 30**


what is that event suppose to mean, if you have any ideas how to set the fireball tween movement (CFrame) to the Cursor's aim or how to fix this , please tell me

(I've tried oCrxptic Solution but that reach's on the output to : ->Unable to cast to Dictionary <-

2 answers

Log in to vote
1
Answered by
Elixcore 1337 Moderation Voter
4 years ago
Edited 4 years ago

EDIT: There are several problems with your code, I shall edit my answer in order to answer them all.

Ok so the 2 problems I have noticed are:

First off, in your localscript you reference the mouse's Position instead of CFrame.

To fix that simply remove the .p from the end in the mousehit variable.

local mousehit = player:GetMouse().Hit

Second off, in your localscript you send the localplayer in the arguments of FireServer

The LocalScript does not need to send the localplayer to the server because the ServerScript automatically gets the player that sent the remote.

Simply edit your localscript code to

FireBallRemote:FireServer(mousehit)
Ad
Log in to vote
2
Answered by
appxritixn 2235 Moderation Voter Community Moderator
4 years ago

As far as I can see, you are setting the CFrame for "info", but are not using it. It looks like you have to change:

local tween1 = TweenService:Create(FireBall, info6, info)

to

local tween1 = TweenService:Create(FireBall, info6, info.CFrame)

Correct me if I am wrong though.

0
Unable to cast to Dictionary -- oCrxptic Zero_Tsou 175 — 4y
1
Why don't you just use the CFrame directly when making the Tween? appxritixn 2235 — 4y
0
I am trying to aim the FireBall at the Cursor's aim, So i used ------ https://developer.roblox.com/en-us/api-reference/property/Mouse/Hit Zero_Tsou 175 — 4y
0
Already used the CFrame directly by using the mouse.Hit.p Zero_Tsou 175 — 4y

Answer this question