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
5 years ago
Edited 5 years ago

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

LocalScript:

01local FireBall = game.Workspace.FireBall
02local rp = game:GetService("ReplicatedStorage")
03local FireBallRemote = rp.RemoteEvents.FireBall
04local UIS = game:GetService("UserInputService")
05local player = game.Players.LocalPlayer
06local mousehit = player:GetMouse().Hit.p
07 
08UIS.InputBegan:Connect(function(input, IsTyping)
09    if IsTyping then
10        return
11 
12    elseif input.KeyCode == Enum.KeyCode.E then
13        FireBallRemote:FireServer(player, mousehit)
14    end
15end)

ServerScript:

01local FireBall = game.Workspace.FireBall:Clone()
02local rp = game:GetService("ReplicatedStorage")
03local FireBallRemote = rp.RemoteEvents.FireBall
04local UIS = game:GetService("UserInputService")
05local TweenService = game:GetService("TweenService")
06 
07FireBallRemote.OnServerEvent:Connect(function(player, mousehit)
08    local Character = player.Character
09    local HumanoidRootPart = Character.HumanoidRootPart
10    local Align = Instance.new("AlignPosition")
11    Align.Enabled = false
12    Align.Parent = HumanoidRootPart
13        Align.Attachment0 = HumanoidRootPart.RootRigAttachment
14    Align.Attachment1 = FireBall.FireBallAttachment
15    Align.RigidityEnabled = true
View all 38 lines...

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
5 years ago
Edited 5 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.

1local 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

1FireBallRemote:FireServer(mousehit)
Ad
Log in to vote
2
Answered by
appxritixn 2235 Moderation Voter Community Moderator
5 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:

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

to

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

Correct me if I am wrong though.

0
Unable to cast to Dictionary -- oCrxptic Zero_Tsou 175 — 5y
1
Why don't you just use the CFrame directly when making the Tween? appxritixn 2235 — 5y
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 — 5y
0
Already used the CFrame directly by using the mouse.Hit.p Zero_Tsou 175 — 5y

Answer this question